Code Duplication    Length = 8-10 lines in 3 locations

src/Validator/Helper/AnyOfTrait.php 1 location

@@ 12-21 (lines=10) @@
9
     * @param array $vals
10
     * @return $this
11
     */
12
    public function anyOf(array $vals)
13
    {
14
        $this->add(function ($value, $nameKey) use ($vals) {
15
            if (!in_array($value, $vals)) {
16
                return $this->createError('anyof', $value, $nameKey);
17
            }
18
        });
19
20
        return $this;
21
    }
22
}
23

src/Validator/AbstractValidator.php 2 locations

@@ 128-137 (lines=10) @@
125
     * @param array $vals
126
     * @return $this
127
     */
128
    public function anyOf(array $vals)
129
    {
130
        $this->add(function ($value, $nameKey) use ($vals) {
131
            if (!in_array($value, $vals)) {
132
                return $this->createError('anyof', $value, $nameKey);
133
            }
134
        });
135
136
        return $this;
137
    }
138
139
    /**
140
     * Validate given value is _not_ in $vals
@@ 145-152 (lines=8) @@
142
     * @param array $vals
143
     * @return AbstractValidator
144
     */
145
    public function invalid(array $vals)
146
    {
147
        return $this->add(function ($value, $nameKey) use ($vals) {
148
            if (in_array($value, $vals)) {
149
                return $this->createError('invalid', $value, $nameKey);
150
            }
151
        });
152
    }
153
154
    /**
155
     * Map value to key in array and grab associated array value, or