Passed
Pull Request — master (#8)
by Sergey
02:00
created

StreamGroupConsumer::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 18
ccs 0
cts 17
cp 0
crap 6
rs 9.9
c 1
b 0
f 1
1
<?php
2
3
4
namespace Asiries335\redisSteamPhp;
5
6
7
use Asiries335\redisSteamPhp\Data\Constants;
8
use Asiries335\redisSteamPhp\Dto\StreamCommandCallTransporter;
9
10
final class StreamGroupConsumer extends RedisStream
11
{
12
    /**
13
     * Create group Consumer
14
     *
15
     * @param string $groupName
16
     * @param bool $isShowFullHistoryStream
17
     *
18
     * @return bool
19
     *
20
     * @throws \Exception
21
     */
22
    public function create(string $groupName, bool $isShowFullHistoryStream = true) : bool
23
    {
24
        $transporter = new StreamCommandCallTransporter(
25
            [
26
                'command' => Constants::COMMAND_XGROUP,
27
                'args'    => [
28
                    'CREATE',
29
                    $this->_streamName,
30
                    $groupName,
31
                    (int) $isShowFullHistoryStream
32
                ]
33
            ]
34
        );
35
36
        try {
37
            return (bool) $this->_client->call($transporter);
38
        } catch (\Exception $exception) {
39
            throw $exception;
40
        }
41
    }
42
}