Code Duplication    Length = 16-16 lines in 2 locations

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

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

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