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