| Conditions | 6 |
| Paths | 6 |
| Total Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | public function items(int $page, int $onPage, array $filter = []): array |
||
| 39 | { |
||
| 40 | $skipped = 0; |
||
| 41 | $offset = ($page - 1) * $onPage; |
||
| 42 | $items = []; |
||
| 43 | foreach ($this->connection->keys('*') as $key) { |
||
| 44 | if ($this->connection->type($key) !== RedisProxy::TYPE_STRING) { |
||
| 45 | continue; |
||
| 46 | } |
||
| 47 | $result = $this->connection->get($key); |
||
| 48 | |||
| 49 | $item = [ |
||
| 50 | 'key' => $key, |
||
| 51 | 'value' => $result, |
||
| 52 | 'length' => strlen($result), |
||
| 53 | ]; |
||
| 54 | |||
| 55 | if (!Filter::apply($item, $filter)) { |
||
| 56 | continue; |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($skipped < $offset) { |
||
| 60 | $skipped++; |
||
| 61 | continue; |
||
| 62 | } |
||
| 63 | |||
| 64 | $items[$key] = $item; |
||
| 65 | if (count($items) === $onPage) { |
||
| 66 | break; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | return $items; |
||
| 70 | } |
||
| 71 | } |
||
| 72 |