| Total Complexity | 3 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | trait DerivationIterationControlTrait |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Setter for the derivation internal iteration count property. |
||
| 26 | * |
||
| 27 | * @param int $numberOfIterations The number of internal iterations to perform. |
||
| 28 | * |
||
| 29 | * @return $this The hash algorithm object. |
||
| 30 | * @throws \Exception Validation errors. |
||
| 31 | */ |
||
| 32 | 30 | public function setDerivationIterations($numberOfIterations) |
|
| 33 | { |
||
| 34 | 30 | $numberOfIterations = filter_var( |
|
| 35 | 30 | $numberOfIterations, |
|
| 36 | 30 | FILTER_VALIDATE_INT, |
|
| 37 | 30 | [ |
|
| 38 | 30 | "options" => [ |
|
| 39 | 30 | "min_range" => 1, |
|
| 40 | 30 | "max_range" => PHP_INT_MAX, |
|
| 41 | 30 | ], |
|
| 42 | 30 | ] |
|
| 43 | 30 | ); |
|
| 44 | |||
| 45 | 30 | if ($numberOfIterations === false) { |
|
| 46 | 15 | throw new \InvalidArgumentException( |
|
| 47 | 15 | 'The number of internal iterations must be a valid integer bigger than 0.' |
|
| 48 | 15 | ); |
|
| 49 | } |
||
| 50 | |||
| 51 | 15 | $this->numberOfIterations = $numberOfIterations; |
|
| 52 | |||
| 53 | 15 | return $this; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Getter for the derivation internal iteration count property. |
||
| 58 | * |
||
| 59 | * @return int The number of internal iterations to perform. |
||
| 60 | */ |
||
| 61 | 15 | public function getDerivationIterations() |
|
| 64 | } |
||
| 65 | } |
||
| 66 |