Conditions | 2 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
38 | 2 | public function hash(string $password): string |
|
39 | { |
||
40 | 2 | set_error_handler([self::class, 'errorHandler']); |
|
41 | try { |
||
42 | 2 | $hash = password_hash($password, $this->algorithm, $this->options); |
|
43 | 1 | } catch (ErrorException $exception) { |
|
44 | 1 | throw new RuntimeException( |
|
45 | 1 | 'An error occurred while hashing the password: '.$exception->getMessage(), |
|
46 | 1 | /*code*/0, |
|
47 | 1 | $exception |
|
48 | ); |
||
49 | 1 | } finally { |
|
50 | 2 | restore_error_handler(); |
|
51 | } |
||
52 | |||
53 | 1 | assert($hash !== false); |
|
54 | |||
55 | 1 | return $hash; |
|
56 | } |
||
74 |