Skip to content

Commit 68ac51a

Browse files
committed
implement contract on manager
1 parent 107565a commit 68ac51a

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

src/Illuminate/Foundation/helpers.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,12 @@ function base_path($path = '')
188188
* Hash the given value against the bcrypt algorithm.
189189
*
190190
* @param string $value
191-
* @param array $options
191+
* @param array $options
192192
* @return string
193193
*/
194194
function bcrypt($value, $options = [])
195195
{
196-
return app('hash')
197-
->driver('bcrypt')
198-
->make($value, $options);
196+
return app('hash')->driver('bcrypt')->make($value, $options);
199197
}
200198
}
201199

src/Illuminate/Hashing/HashManager.php

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
namespace Illuminate\Hashing;
44

55
use Illuminate\Support\Manager;
6+
use Illuminate\Contracts\Hashing\Hasher;
67

7-
class HashManager extends Manager
8+
class HashManager extends Manager implements Hasher
89
{
9-
/**
10-
* Get the default driver name.
11-
*
12-
* @return string
13-
*/
14-
public function getDefaultDriver()
15-
{
16-
return $this->app['config']['hashing.driver'];
17-
}
18-
1910
/**
2011
* Create an instance of the Brycrypt hash Driver.
2112
*
@@ -35,4 +26,51 @@ public function createArgonDriver()
3526
{
3627
return new ArgonHasher;
3728
}
38-
}
29+
30+
/**
31+
* Hash the given value.
32+
*
33+
* @param string $value
34+
* @param array $options
35+
* @return string
36+
*/
37+
public function make($value, array $options = [])
38+
{
39+
return $this->driver()->make($value, $options);
40+
}
41+
42+
/**
43+
* Check the given plain value against a hash.
44+
*
45+
* @param string $value
46+
* @param string $hashedValue
47+
* @param array $options
48+
* @return bool
49+
*/
50+
public function check($value, $hashedValue, array $options = [])
51+
{
52+
return $this->driver()->check($value, $hashedValue, $options);
53+
}
54+
55+
/**
56+
* Check if the given hash has been hashed using the given options.
57+
*
58+
* @param string $hashedValue
59+
* @param array $options
60+
* @return bool
61+
*/
62+
public function needsRehash($hashedValue, array $options = [])
63+
{
64+
return $this->driver()->needsRehash($hashedValue, $options);
65+
}
66+
67+
/**
68+
* Get the default driver name.
69+
*
70+
* @return string
71+
*/
72+
public function getDefaultDriver()
73+
{
74+
return $this->app['config']['hashing.driver'];
75+
}
76+
}

0 commit comments

Comments
 (0)