KeyValueCollection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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