• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

predis / predis / 15628651118

13 Jun 2025 07:07AM UTC coverage: 92.746% (+0.02%) from 92.729%
15628651118

push

github

web-flow
implement XCLAIM command (#1557)

* implement XCLAIM command

* modify CHANGELOG.md

* add empty line before return

* test xclaim with all available options

* review refactoring

* remove fast-track check for empty answer

---------

Co-authored-by: aleksanders <alexander.s@seranking.com>

31 of 32 new or added lines in 1 file covered. (96.88%)

7339 of 7913 relevant lines covered (92.75%)

111.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.88
/src/Command/Redis/XCLAIM.php
1
<?php
2

3
/*
4
 * This file is part of the Predis package.
5
 *
6
 * (c) 2009-2020 Daniele Alessandri
7
 * (c) 2021-2025 Till Krüss
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12

13
namespace Predis\Command\Redis;
14

15
use Predis\Command\PrefixableCommand as RedisCommand;
16
use Predis\Command\Redis\Utils\CommandUtility;
17

18
/**
19
 * @see http://redis.io/commands/xclaim
20
 */
21
class XCLAIM extends RedisCommand
22
{
23
    public function getId(): string
3✔
24
    {
25
        return 'XCLAIM';
3✔
26
    }
27

28
    public function setArguments(array $arguments): void
12✔
29
    {
30
        if (count($arguments) < 5) {
12✔
NEW
31
            return;
×
32
        }
33

34
        $processedArguments = array_slice($arguments, 0, 4);
12✔
35
        $ids = $arguments[4];
12✔
36
        $processedArguments = array_merge($processedArguments, is_array($ids) ? $ids : [$ids]);
12✔
37

38
        if (array_key_exists(5, $arguments) && null !== $arguments[5]) {
12✔
39
            array_push($processedArguments, 'IDLE', $arguments[5]);
4✔
40
        }
41

42
        if (array_key_exists(6, $arguments) && null !== $arguments[6]) {
12✔
43
            array_push($processedArguments, 'TIME', $arguments[6]);
4✔
44
        }
45

46
        if (array_key_exists(7, $arguments) && null !== $arguments[7]) {
12✔
47
            array_push($processedArguments, 'RETRYCOUNT', $arguments[7]);
4✔
48
        }
49

50
        if (array_key_exists(8, $arguments) && false !== $arguments[8]) {
12✔
51
            $processedArguments[] = 'FORCE';
4✔
52
        }
53

54
        if (array_key_exists(9, $arguments) && false !== $arguments[9]) {
12✔
55
            $processedArguments[] = 'JUSTID';
4✔
56
        }
57

58
        if (array_key_exists(10, $arguments) && false !== $arguments[10]) {
12✔
59
            array_push($processedArguments, 'LASTID', $arguments[10]);
4✔
60
        }
61

62
        parent::setArguments($processedArguments);
12✔
63
    }
64

65
    public function parseResponse($data): array
3✔
66
    {
67
        // JUSTID format
68
        if (isset($data[0]) && !is_array($data[0])) {
3✔
69
            return $data;
3✔
70
        }
71

72
        $result = [];
3✔
73
        foreach ($data as [$id, $kvDict]) {
3✔
74
            $result[$id] = CommandUtility::arrayToDictionary($kvDict);
3✔
75
        }
76

77
        return $result;
3✔
78
    }
79

80
    public function parseResp3Response($data): array
2✔
81
    {
82
        return $this->parseResponse($data);
2✔
83
    }
84

85
    public function prefixKeys($prefix)
1✔
86
    {
87
        $this->applyPrefixForFirstArgument($prefix);
1✔
88
    }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc