Code Duplication    Length = 14-14 lines in 3 locations

Validator.php 3 locations

@@ 86-99 (lines=14) @@
83
     *
84
     * @return self
85
     */
86
    public function array(array $array, array $rules, array $messages = [], $group = null)
87
    {
88
        if (null !== $group && (!is_string($group) || !is_int($group))) {
89
            throw new InvalidArgumentException('The group must be either a string or an integer');
90
        }
91
92
        foreach ($rules as $key => $options) {
93
            $value = $array[$key] ?? null;
94
95
            $this->value($value, $key, $options, $messages, $group);
96
        }
97
98
        return $this;
99
    }
100
101
    /**
102
     * Validates an objects properties with the given rules.
@@ 111-124 (lines=14) @@
108
     *
109
     * @return self
110
     */
111
    public function object(object $object, array $rules, array $messages = [], $group = null)
112
    {
113
        if (null !== $group && (!is_string($group) || !is_int($group))) {
114
            throw new InvalidArgumentException('The group must be either a string or an integer');
115
        }
116
117
        foreach ($rules as $property => $options) {
118
            $value = $this->getPropertyValue($object, $property);
119
120
            $this->value($value, $property, $options, $messages, $group);
121
        }
122
123
        return $this;
124
    }
125
126
    /**
127
     * Validates request parameters with the given rules.
@@ 136-149 (lines=14) @@
133
     *
134
     * @return self
135
     */
136
    public function request(Request $request, array $rules, array $messages = [], $group = null)
137
    {
138
        if (null !== $group && (!is_string($group) || !is_int($group))) {
139
            throw new InvalidArgumentException('The group must be either a string or an integer');
140
        }
141
142
        foreach ($rules as $param => $options) {
143
            $value = $this->getRequestParam($request, $param);
144
145
            $this->value($value, $param, $options, $messages, $group);
146
        }
147
148
        return $this;
149
    }
150
151
    /**
152
     * Validates request parameters, an array or an objects properties.