Code Duplication    Length = 16-16 lines in 2 locations

src/RunOpenCode/ExchangeRate/Repository/MemoryRepository.php 1 location

@@ 176-191 (lines=16) @@
173
     * @param array $criteria Filter criteria.
174
     * @return RateInterface[] Paginated rates.
175
     */
176
    protected function paginate(array $rates, $criteria)
177
    {
178
        if (!array_key_exists('offset', $criteria) && !array_key_exists('limit', $criteria)) {
179
            return $rates;
180
        }
181
182
        $range = array();
183
        $offset = array_key_exists('offset', $criteria) ? $criteria['offset'] : 0;
184
        $limit = min((array_key_exists('limit', $criteria) ? $criteria['limit'] : count($rates)) + $offset, count($rates));
185
186
        for ($i = $offset; $i < $limit; $i++) {
187
            $range[] = $rates[$i];
188
        }
189
190
        return $range;
191
    }
192
}
193

src/RunOpenCode/ExchangeRate/Repository/FileRepository.php 1 location

@@ 320-335 (lines=16) @@
317
     * @param array $criteria Filter criteria.
318
     * @return RateInterface[] Paginated rates.
319
     */
320
    protected function paginate(array $rates, $criteria)
321
    {
322
        if (!array_key_exists('offset', $criteria) && !array_key_exists('limit', $criteria)) {
323
            return $rates;
324
        }
325
326
        $range = array();
327
        $offset = array_key_exists('offset', $criteria) ? $criteria['offset'] : 0;
328
        $limit = min((array_key_exists('limit', $criteria) ? $criteria['limit'] : count($rates)) + $offset, count($rates));
329
330
        for ($i = $offset; $i < $limit; $i++) {
331
            $range[] = $rates[$i];
332
        }
333
334
        return $range;
335
    }
336
}
337