Code Duplication    Length = 17-18 lines in 2 locations

src/Valdi/Validator/MaxLength.php 1 location

@@ 17-33 (lines=17) @@
14
/**
15
 * Validator for strings of a max length.
16
 */
17
class MaxLength extends Comparator {
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function compare($a, $parameters) {
23
        return is_numeric($parameters[0]) && strlen($a) <= $parameters[0];
24
    }
25
26
    /**
27
     * Constructor.
28
     */
29
    public function __construct() {
30
        parent::__construct();
31
        $this->type = 'maxLength';
32
    }
33
}
34

src/Valdi/Validator/MinLength.php 1 location

@@ 17-34 (lines=18) @@
14
/**
15
 * Validator for strings of a min length.
16
 */
17
class MinLength extends Comparator {
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function compare($a, $parameters) {
23
        $length = strlen($a);
24
        return is_numeric($parameters[0]) && $length >= $parameters[0];
25
    }
26
27
    /**
28
     * Constructor.
29
     */
30
    public function __construct() {
31
        parent::__construct();
32
        $this->type = 'minLength';
33
    }
34
}
35