Code Duplication    Length = 14-14 lines in 2 locations

src/Zicht/Itertools/filters.php 2 locations

@@ 153-166 (lines=14) @@
150
    $strategy = conversions\mixed_to_value_getter($strategy);
151
152
    // Support DateTimeInterface
153
    if ($expected instanceof \DateTimeInterface) {
154
        return function ($value, $key = null) use ($expected, $strategy, $orEqual) {
155
            $value = $strategy($value, $key);
156
            // Try to convert strings that are longer than 3 characters.  This simple test will ensure
157
            // that '' or 'now' will not be accepted.
158
            if (is_string($value) && strlen($value) > 3) {
159
                try {
160
                    $value = new \DateTimeImmutable($value);
161
                } catch (\Exception $exception) {
162
                }
163
            }
164
            return $value instanceof \DateTimeInterface && ($orEqual ? $expected <= $value : $expected < $value);
165
        };
166
    }
167
168
    // Support numbers
169
    if (is_int($expected) || is_float($expected)) {
@@ 201-214 (lines=14) @@
198
    $strategy = conversions\mixed_to_value_getter($strategy);
199
200
    // Support DateTimeInterface
201
    if ($expected instanceof \DateTimeInterface) {
202
        return function ($value, $key = null) use ($expected, $strategy, $orEqual) {
203
            $value = $strategy($value, $key);
204
            // Try to convert strings that are longer than 3 characters.  This simple test will ensure
205
            // that '' or 'now' will not be accepted.
206
            if (is_string($value) && strlen($value) > 3) {
207
                try {
208
                    $value = new \DateTimeImmutable($value);
209
                } catch (\Exception $exception) {
210
                }
211
            }
212
            return $value instanceof \DateTimeInterface && ($orEqual ? $expected >= $value : $expected > $value);
213
        };
214
    }
215
216
    // Support numbers
217
    if (is_int($expected) || is_float($expected)) {