Code Duplication    Length = 24-25 lines in 2 locations

app/Drivers/Redis/DataManager/RedisSetDataManager.php 1 location

@@ 17-40 (lines=24) @@
14
        $this->connection = $connection;
15
    }
16
17
    public function itemsCount(string $table, array $filter): int
18
    {
19
        if (!$filter) {
20
            return $this->connection->scard($table);
21
        }
22
        $iterator = '';
23
        $totalItems = 0;
24
        do {
25
            $res = $this->connection->sscan($table, $iterator, null, 1000);
26
            if (!$res) {
27
                return $totalItems;
28
            }
29
            foreach ($res as $member) {
30
                $item = [
31
                    'member' => $member,
32
                    'length' => strlen($member),
33
                ];
34
                if (Filter::apply($item, $filter)) {
35
                    $totalItems++;
36
                }
37
            }
38
        } while ($iterator !== 0);
39
        return $totalItems;
40
    }
41
42
    public function items(string $table, int $page, int $onPage, array $filter = []): array
43
    {

app/Drivers/Redis/DataManager/RedisSortedSetDataManager.php 1 location

@@ 17-41 (lines=25) @@
14
        $this->connection = $connection;
15
    }
16
17
    public function itemsCount(string $table, array $filter): int
18
    {
19
        if (!$filter) {
20
            return $this->connection->zcard($table);
21
        }
22
        $iterator = '';
23
        $totalItems = 0;
24
        do {
25
            $res = $this->connection->zscan($table, $iterator, null, 1000);
26
            if (!$res) {
27
                return $totalItems;
28
            }
29
            foreach ($res as $member => $score) {
30
                $item = [
31
                    'member' => $member,
32
                    'length' => strlen($member),
33
                    'score' => $score,
34
                ];
35
                if (Filter::apply($item, $filter)) {
36
                    $totalItems++;
37
                }
38
            }
39
        } while ($iterator !== 0);
40
        return $totalItems;
41
    }
42
43
    public function items(string $table, int $page, int $onPage, array $filter = []): array
44
    {