Code Duplication    Length = 70-81 lines in 2 locations

src/Weew/ConfigSchema/Nodes/ArrayNode.php 1 location

@@ 15-95 (lines=81) @@
12
use Weew\Validator\Constraints\NotNullConstraint;
13
use Weew\Validator\Constraints\NullableConstraint;
14
15
class ArrayNode extends Node implements IArrayNode {
16
    /**
17
     * ArrayNode constructor.
18
     *
19
     * @param IConfigSchema $schema
20
     * @param string $key
21
     * @param string $message
22
     */
23
    public function __construct(IConfigSchema $schema, $key, $message = null) {
24
        parent::__construct($schema, $key);
25
26
        $this->constraints([
27
            new NotNullConstraint($message),
28
            new ArrayConstraint(),
29
        ]);
30
    }
31
32
    /**
33
     * @param int $min
34
     *
35
     * @return IArrayNode
36
     */
37
    public function min($min) {
38
        return $this->constraint(
39
            new MinLengthConstraint($min)
40
        );
41
    }
42
43
    /**
44
     * @param int $max
45
     *
46
     * @return IArrayNode
47
     */
48
    public function max($max) {
49
        return $this->constraint(
50
            new MaxLengthConstraint($max)
51
        );
52
    }
53
54
    /**
55
     * @param int $length
56
     *
57
     * @return IArrayNode
58
     */
59
    public function length($length) {
60
        return $this->constraint(
61
            new LengthConstraint($length)
62
        );
63
    }
64
65
    /**
66
     * @param array $values
67
     *
68
     * @return IArrayNode
69
     */
70
    public function allowed(array $values) {
71
        return $this->constraint(
72
            new AllowedSubsetConstraint($values)
73
        );
74
    }
75
76
    /**
77
     * @param array $values
78
     *
79
     * @return IArrayNode
80
     */
81
    public function forbidden(array $values) {
82
        return $this->constraint(
83
            new ForbiddenSubsetConstraint($values)
84
        );
85
    }
86
87
    /**
88
     * @return IArrayNode
89
     */
90
    public function nullable() {
91
        return $this->constraint(
92
            new NullableConstraint()
93
        );
94
    }
95
}
96

src/Weew/ConfigSchema/Nodes/NumericNode.php 1 location

@@ 14-83 (lines=70) @@
11
use Weew\Validator\Constraints\NullableConstraint;
12
use Weew\Validator\Constraints\NumericConstraint;
13
14
class NumericNode extends Node implements INumericNode {
15
    /**
16
     * NumericNode constructor.
17
     *
18
     * @param IConfigSchema $schema
19
     * @param string $key
20
     * @param string $message
21
     */
22
    public function __construct(IConfigSchema $schema, $key, $message = null) {
23
        parent::__construct($schema, $key);
24
25
        $this->constraints([
26
            new NotNullConstraint($message),
27
            new NumericConstraint(),
28
        ]);
29
    }
30
31
    /**
32
     * @param int $min
33
     *
34
     * @return INumericNode
35
     */
36
    public function min($min) {
37
        return $this->constraint(
38
            new MinConstraint($min)
39
        );
40
    }
41
42
    /**
43
     * @param int $max
44
     *
45
     * @return INumericNode
46
     */
47
    public function max($max) {
48
        return $this->constraint(
49
            new MaxConstraint($max)
50
        );
51
    }
52
53
    /**
54
     * @param array $values
55
     *
56
     * @return INumericNode
57
     */
58
    public function allowed(array $values) {
59
        return $this->constraint(
60
            new AllowedConstraint($values)
61
        );
62
    }
63
64
    /**
65
     * @param array $values
66
     *
67
     * @return INumericNode
68
     */
69
    public function forbidden(array $values) {
70
        return $this->constraint(
71
            new ForbiddenConstraint($values)
72
        );
73
    }
74
75
    /**
76
     * @return INumericNode
77
     */
78
    public function nullable() {
79
        return $this->constraint(
80
            new NullableConstraint()
81
        );
82
    }
83
}
84