Code Duplication    Length = 13-13 lines in 2 locations

src/Zicht/Itertools/util/Filters.php 2 locations

@@ 130-142 (lines=13) @@
127
        $strategy = Conversions::mixedToValueGetter($strategy);
128
129
        // Support DateTimeInterface
130
        if ($expected instanceof \DateTimeInterface) {
131
            return function ($value, $key = null) use ($expected, $strategy, $orEqual) {
132
                $value = $strategy($value, $key);
133
                // Try to convert strings that look like ISO date format
134
                if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) {
135
                    try {
136
                        $value = new \DateTimeImmutable($value);
137
                    } catch (\Exception $exception) {
138
                    }
139
                }
140
                return $value instanceof \DateTimeInterface && ($orEqual ? $expected <= $value : $expected < $value);
141
            };
142
        }
143
144
        // Support numbers
145
        if (is_int($expected) || is_float($expected)) {
@@ 177-189 (lines=13) @@
174
        $strategy = Conversions::mixedToValueGetter($strategy);
175
176
        // Support DateTimeInterface
177
        if ($expected instanceof \DateTimeInterface) {
178
            return function ($value, $key = null) use ($expected, $strategy, $orEqual) {
179
                $value = $strategy($value, $key);
180
                // Try to convert strings that look like ISO date format
181
                if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) {
182
                    try {
183
                        $value = new \DateTimeImmutable($value);
184
                    } catch (\Exception $exception) {
185
                    }
186
                }
187
                return $value instanceof \DateTimeInterface && ($orEqual ? $expected >= $value : $expected > $value);
188
            };
189
        }
190
191
        // Support numbers
192
        if (is_int($expected) || is_float($expected)) {