ArrayInsert   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A createCommandWithArguments() 0 11 1
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