From 68ac51a3c85d039799d32f53a045328e14debfea Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 6 Nov 2017 07:59:37 -0600 Subject: [PATCH] implement contract on manager --- src/Illuminate/Foundation/helpers.php | 6 +-- src/Illuminate/Hashing/HashManager.php | 62 +++++++++++++++++++++----- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index b5e6b3a5bc45..864584a69450 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -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); } } diff --git a/src/Illuminate/Hashing/HashManager.php b/src/Illuminate/Hashing/HashManager.php index f0b56c6e8d80..3f51c184e730 100644 --- a/src/Illuminate/Hashing/HashManager.php +++ b/src/Illuminate/Hashing/HashManager.php @@ -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. * @@ -35,4 +26,51 @@ public function createArgonDriver() { return new ArgonHasher; } -} \ No newline at end of file + + /** + * 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']; + } +}