Code Duplication    Length = 12-16 lines in 2 locations

Validator.php 2 locations

@@ 116-131 (lines=16) @@
113
     *
114
     * @return self
115
     */
116
    public function object($object, array $rules, string $group = null, array $messages = [], $default = null): self
117
    {
118
        if (!is_object($object)) {
119
            throw new InvalidArgumentException('The first argument should be an object');
120
        }
121
122
        foreach ($rules as $property => $options) {
123
            $config = new Configuration($options, $property, $group, $default);
124
125
            $value = $this->getPropertyValue($object, $property, $config->getDefault());
126
127
            $this->validateInput($value, $config, $messages);
128
        }
129
130
        return $this;
131
    }
132
133
    /**
134
     * Validates request parameters with the given rules.
@@ 144-155 (lines=12) @@
141
     *
142
     * @return self
143
     */
144
    public function request(Request $request, array $rules, string $group = null, array $messages = [], $default = null): self
145
    {
146
        foreach ($rules as $param => $options) {
147
            $config = new Configuration($options, $param, $group, $default);
148
149
            $value = $this->getRequestParam($request, $param, $config->getDefault());
150
151
            $this->validateInput($value, $config, $messages);
152
        }
153
154
        return $this;
155
    }
156
157
    /**
158
     * Validates request parameters, an array or an objects properties.