Passed
Pull Request — master (#15)
by Mattia
18:42 queued 15:28
created

OperationData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cypress\PatchManager;
6
7
use Cypress\PatchManager\Request\Operations;
8
use PhpCollection\Map;
9
use PhpCollection\Sequence;
10
use PhpOption\Option;
11
12
class OperationData extends Map
13
{
14
    /**
15
     * @return Option<string>
16
     */
17 2
    public function getOp(): Option
18
    {
19 2
        return $this->get(Operations::OP_KEY_NAME);
20
    }
21
22 6
    public function getData(): Map
23
    {
24 6
        $operationData = new Map($this->elements);
25 6
        if ($operationData->containsKey(Operations::OP_KEY_NAME)) {
26 5
            $operationData->remove(Operations::OP_KEY_NAME);
27
        }
28
29 6
        return $operationData;
30
    }
31
32 3
    public function diffKeys(array $keys): Sequence
33
    {
34 3
        $filtered = array_filter(
35 3
            $this->getData()->keys(),
36 3
            static fn ($key) => !in_array($key, $keys)
37 3
        );
38
39 3
        return new Sequence($filtered);
40
    }
41
}
42