ArrayInsert::createCommandWithArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Redislabs\Module\ReJSON\Command;
5
6
use Redislabs\Interfaces\CommandInterface;
7
use Redislabs\Command\CommandAbstract;
8
use Redislabs\Module\ReJSON\Path;
9
10
final class ArrayInsert extends CommandAbstract implements CommandInterface
11
{
12
    protected static $command = 'JSON.ARRINSERT';
13
14
    private function __construct(
15
        string $key,
16
        Path $path,
17
        int $index,
18
        array $jsons
19
    ) {
20
        $this->arguments = array_merge([$key, $path->getPath(), $index], $jsons);
21
    }
22
23
    public static function createCommandWithArguments(
24
        string $key,
25
        string $path,
26
        int $index,
27
        array $jsons
28
    ) : CommandInterface {
29
        return new self(
30
            $key,
31
            new Path($path),
32
            $index,
33
            array_map('json_encode', $jsons)
34
        );
35
    }
36
}
37