KeyValueCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 8 1
A get() 0 4 1
A count() 0 4 1
1
<?php
2
namespace Loevgaard\Dandomain\Api\KeyValue;
3
4
/**
5
 * The key value collection will hold a data structure like this:
6
 *
7
 * [
8
 *   'keyValues' => [
9
 *     ['Key' => 'property', 'Value' => 'new value of property']
10
 *   ]
11
 * ]
12
 *
13
 * which can be used in the patch methods
14
 */
15
class KeyValueCollection implements \Countable
16
{
17
    /**
18
     * @var array
19
     */
20
    private $arr;
21
22 3
    public function __construct()
23
    {
24 3
        $this->arr = ['keyValues' => []];
25 3
    }
26
27 3
    public function add(string $key, string $value) : KeyValueCollection
28
    {
29 3
        $this->arr['keyValues'][] = [
30 3
            'Key' => $key, 'Value' => $value
31
        ];
32
33 3
        return $this;
34
    }
35
36 1
    public function get() : array
37
    {
38 1
        return $this->arr;
39
    }
40
41 1
    public function count()
42
    {
43 1
        return count($this->arr['keyValues']);
44
    }
45
}
46