Passed
Pull Request — master (#15)
by Mattia
30:41 queued 16:42
created

OperationData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
c 0
b 0
f 0
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 8 2
A getOp() 0 3 1
A diffKeys() 0 8 1
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