| Total Complexity | 5 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class WordPressHasher extends AbstractHasher implements Hasher |
||
| 10 | { |
||
| 11 | protected $hasher; |
||
| 12 | |||
| 13 | public function __construct(PasswordHash $hasher) |
||
| 14 | { |
||
| 15 | $this->hasher = $hasher; |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Hash the given value. |
||
| 20 | * |
||
| 21 | * @param string $value |
||
| 22 | * @param array $options |
||
| 23 | * @return string |
||
| 24 | */ |
||
| 25 | public function make($value, array $options = array()) |
||
| 26 | { |
||
| 27 | return $this->hasher->HashPassword($value); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Check the given plain value against a hash. |
||
| 32 | * |
||
| 33 | * @param string $value |
||
| 34 | * @param string $hashedValue |
||
| 35 | * @param array $options |
||
| 36 | * @return bool |
||
| 37 | */ |
||
| 38 | public function check($value, $hashedValue, array $options = array()) |
||
| 39 | { |
||
| 40 | if ( strlen($hashedValue) <= 32 ) { |
||
| 41 | return $hashedValue == md5($value); |
||
| 42 | } |
||
| 43 | |||
| 44 | $check = $this->hasher->CheckPassword($value, $hashedValue); |
||
| 45 | |||
| 46 | return $check; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Check if the given hash has been hashed using the given options. |
||
| 51 | * |
||
| 52 | * @param string $hashedValue |
||
| 53 | * @param array $options |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public function needsRehash($hashedValue, array $options = array()) |
||
| 59 | } |
||
| 60 | } |
||
| 61 |