| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 8 | public function validate($value, $parameter, Validator $validator) |
|
| 31 | { |
||
| 32 | 8 | Assert::type($parameter, 'number', self::KEYWORD, $validator->getSchemaPath()); |
|
| 33 | 6 | Assert::nonNegative($parameter, self::KEYWORD, $validator->getSchemaPath()); |
|
| 34 | |||
| 35 | 4 | if (!is_numeric($value)) { |
|
| 36 | 2 | return null; |
|
| 37 | } |
||
| 38 | |||
| 39 | 4 | $quotient = bcdiv($value, $parameter, $this->precision); |
|
| 40 | 4 | $mod = bcsub($quotient, floor($quotient), $this->precision); |
|
| 41 | 4 | if (bccomp($mod, 0, $this->precision) === 0) { |
|
| 42 | 4 | return null; |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | return error('The number must be a multiple of {parameter}.', $validator); |
|
| 46 | } |
||
| 47 | } |
||
| 48 |