Code Duplication    Length = 16-16 lines in 2 locations

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

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

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

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