Test Failed
Push — bump-dependencies ( 31c8d5...b4f034 )
by Mattia
13:38 queued 01:08
created

OperationData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A diffKeys() 0 8 1
A getData() 0 8 2
A getOp() 0 3 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 14
class OperationData extends Map
13
{
14 14
    public function getOp(): Option
15
    {
16
        return $this->get(Operations::OP_KEY_NAME);
17
    }
18
19
    public function getData(): Map
20 2
    {
21
        $operationData = new Map($this->elements);
22 2
        if ($operationData->containsKey(Operations::OP_KEY_NAME)) {
23
            $operationData->remove(Operations::OP_KEY_NAME);
24
        }
25
26
        return $operationData;
27
    }
28 6
29
    /**
30 6
     * @param array $keys
31 6
     * @return Sequence
32 5
     */
33
    public function diffKeys(array $keys): Sequence
34
    {
35 6
        $filtered = array_filter(
36
            $this->getData()->keys(),
37
            static fn ($key) => !in_array($key, $keys)
38
        );
39
40
        return new Sequence($filtered);
41
    }
42
}
43