OperationData   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A diffKeys() 0 5 1
A getData() 0 8 2
A getOp() 0 3 1
1
<?php
2
3
namespace Cypress\PatchManager;
4
5
use Cypress\PatchManager\Request\Operations;
6
use PhpCollection\Map;
7
use PhpCollection\Sequence;
8
use PhpOption\Option;
9
10
class OperationData extends Map
11
{
12 14
    public function __construct(array $elements = [])
13
    {
14 14
        parent::__construct($elements);
15
    }
16
17
    /**
18
     * @return Option
19
     */
20 2
    public function getOp(): Option
21
    {
22 2
        return $this->get(Operations::OP_KEY_NAME);
23
    }
24
25
    /**
26
     * @return Map
27
     */
28 6
    public function getData(): Map
29
    {
30 6
        $operationData = new Map($this->elements);
31 6
        if ($operationData->containsKey(Operations::OP_KEY_NAME)) {
32 5
            $operationData->remove(Operations::OP_KEY_NAME);
33
        }
34
35 6
        return $operationData;
36
    }
37
38
    /**
39
     * @param array $keys
40
     * @return Sequence
41
     */
42 3
    public function diffKeys(array $keys): Sequence
43
    {
44 3
        $filtered = array_filter($this->getData()->keys(), fn ($key) => !in_array($key, $keys));
45
46 3
        return new Sequence($filtered);
47
    }
48
}
49