Skip to content

Commit

Permalink
implement contract on manager
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 6, 2017
1 parent 107565a commit 68ac51a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,12 @@ function base_path($path = '')
* Hash the given value against the bcrypt algorithm.
*
* @param string $value
* @param array $options
* @param array $options
* @return string
*/
function bcrypt($value, $options = [])
{
return app('hash')
->driver('bcrypt')
->make($value, $options);
return app('hash')->driver('bcrypt')->make($value, $options);
}
}

Expand Down
62 changes: 50 additions & 12 deletions src/Illuminate/Hashing/HashManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
namespace Illuminate\Hashing;

use Illuminate\Support\Manager;
use Illuminate\Contracts\Hashing\Hasher;

class HashManager extends Manager
class HashManager extends Manager implements Hasher
{
/**
* Get the default driver name.
*
* @return string
*/
public function getDefaultDriver()
{
return $this->app['config']['hashing.driver'];
}

/**
* Create an instance of the Brycrypt hash Driver.
*
Expand All @@ -35,4 +26,51 @@ public function createArgonDriver()
{
return new ArgonHasher;
}
}

/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*/
public function make($value, array $options = [])
{
return $this->driver()->make($value, $options);
}

/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = [])
{
return $this->driver()->check($value, $hashedValue, $options);
}

/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = [])
{
return $this->driver()->needsRehash($hashedValue, $options);
}

/**
* Get the default driver name.
*
* @return string
*/
public function getDefaultDriver()
{
return $this->app['config']['hashing.driver'];
}
}

0 comments on commit 68ac51a

Please sign in to comment.