| Total Complexity | 3 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | class HashAlgorithm |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | private $value; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * HashAlgorithm constructor. |
||
| 36 | * @param string $value |
||
| 37 | * @throws InvalidArgumentException |
||
| 38 | */ |
||
| 39 | 3 | public function __construct(string $value = 'sha256') |
|
| 40 | { |
||
| 41 | try { |
||
| 42 | 3 | Assertion::inArray($value, hash_algos()); |
|
| 43 | 1 | } catch (AssertionFailedException $e) { |
|
| 44 | 1 | throw InvalidArgumentException::fromException($e); |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | $this->value = $value; |
|
| 48 | 2 | } |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 2 | public function __toString(): string |
|
| 56 | } |
||
| 57 | } |
||
| 58 |