KVs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withoutPath() 0 3 1
A __construct() 0 4 2
1
<?php
2
/**
3
 * Key and values
4
 * User: moyo
5
 * Date: 16/10/2017
6
 * Time: 11:49 AM
7
 */
8
9
namespace Carno\Consul\Types;
10
11
use Carno\Consul\Chips\SVersions;
12
use ArrayObject;
13
14
class KVs extends ArrayObject
15
{
16
    use SVersions;
17
18
    /**
19
     * KVs constructor.
20
     * @param string $path
21
     * @param array $data
22
     */
23
    public function __construct(string $path, array $data)
24
    {
25
        foreach ($data as $kv) {
26
            $this->offsetSet($this->withoutPath($path, $kv['Key']), base64_decode($kv['Value']));
27
        }
28
    }
29
30
    /**
31
     * @param string $path
32
     * @param string $key
33
     * @return string
34
     */
35
    private function withoutPath(string $path, string $key) : string
36
    {
37
        return substr($key, strlen($path) + 1);
38
    }
39
}
40