KVTest::testFilterKeysValues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 22
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 31
rs 9.568
1
<?php
2
3
namespace TraitsTests;
4
5
6
use kalanis\kw_input\Interfaces;
7
use kalanis\kw_input\Entries;
8
use kalanis\kw_input\Traits;
9
10
11
class KVTest extends ATraitsTest
12
{
13
    public function testFilterKeysValues(): void
14
    {
15
        $lib = new XTKV();
16
        $data = $lib->unpackValues($this->inputEntries());
17
18
        $item = reset($data);
19
        $this->assertNotFalse($item);
20
        $this->assertEquals('foo', key($data));
21
        /** @var Entries\Entry $item */
22
        $this->assertEquals(Interfaces\IEntry::SOURCE_ENV, $item->getSource());
23
        $this->assertEquals('foo', $item->getKey());
24
        $this->assertEquals('mjgdf', $item->getValue());
25
26
        $item = next($data);
27
        $this->assertNotFalse($item);
28
        $this->assertEquals('bar', key($data));
29
        /** @var Entries\Entry $item */
30
        $this->assertEquals(Interfaces\IEntry::SOURCE_ENV, $item->getSource());
31
        $this->assertEquals('bar', $item->getKey());
32
        $this->assertEquals('shshh', $item->getValue());
33
34
        $item = next($data);
35
        $this->assertNotFalse($item);
36
        $this->assertEquals('baz', key($data));
37
        /** @var Entries\Entry $item */
38
        $this->assertEquals(Interfaces\IEntry::SOURCE_EXTERNAL, $item->getSource());
39
        $this->assertEquals('baz', $item->getKey());
40
        $this->assertEquals('gnbgy', $item->getValue());
41
42
        $item = next($data);
43
        $this->assertFalse($item);
44
    }
45
}
46
47
48
class XTKV
49
{
50
    use Traits\TKV;
51
52
    public function unpackValues(array $entries): array
53
    {
54
        return $this->keysValues($entries);
55
    }
56
}
57