Code Duplication    Length = 15-15 lines in 2 locations

src/Valdi/Validator/Max.php 1 location

@@ 19-33 (lines=15) @@
16
/**
17
 * Validator for max values.
18
 */
19
class Max implements ValidatorInterface {
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function validate($value, array $parameters) {
25
26
        if (count($parameters) !== 1) {
27
            throw new ValidationException('"max" expects one parameter.');
28
        }
29
30
        return $value === '' || $value === null ||
31
            (is_numeric($value) && $value <= $parameters[0]);
32
    }
33
}
34

src/Valdi/Validator/Min.php 1 location

@@ 19-33 (lines=15) @@
16
/**
17
 * Validator for min values.
18
 */
19
class Min implements ValidatorInterface {
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function validate($value, array $parameters) {
25
26
        if (count($parameters) !== 1) {
27
            throw new ValidationException('"min" expects one parameter.');
28
        }
29
30
        return $value === '' || $value === null ||
31
            (is_numeric($value) && $value >= $parameters[0]);
32
    }
33
}
34