TableDelegationTrait::keys()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Bdf\Collection\Util\Extension;
4
5
use Bdf\Collection\TableInterface;
6
7
/**
8
 * Trait for implements TableInterface delegation objects
9
 *
10
 * <code>
11
 * class MyDelegate implements TableInterface
12
 * {
13
 *     use TableDelegationTrait;
14
 *
15
 *     public function __construct(TableInterface $collection)
16
 *     {
17
 *         $this->setCollection($collection);
18
 *     }
19
 * }
20
 * </code>
21
 *
22
 * @see TableInterface
23
 */
24
trait TableDelegationTrait
25
{
26
    use CollectionDelegationTrait;
27
28
    /**
29
     * @var TableInterface
30
     */
31
    private $collection;
32
33
34
    /**
35
     * Set the inner table instance
36
     *
37
     * @param TableInterface $collection
38
     *
39
     * @return void
40
     */
41 7
    private function setCollection(TableInterface $collection): void
42
    {
43 7
        $this->collection = $collection;
44 7
    }
45
46
    /**
47
     * @see TableInterface::set($key, $value)
48
     */
49 1
    public function set($key, $value): void
50
    {
51 1
        $this->collection->set($key, $value);
52 1
    }
53
54
    /**
55
     * @see TableInterface::&get($key)
56
     */
57 1
    public function &get($key)
58
    {
59 1
        return $this->collection->get($key);
60
    }
61
62
    /**
63
     * @see TableInterface::hasKey($key)
64
     */
65 1
    public function hasKey($key): bool
66
    {
67 1
        return $this->collection->hasKey($key);
68
    }
69
70
    /**
71
     * @see TableInterface::unset($key)
72
     */
73 1
    public function unset($key): bool
74
    {
75 1
        return $this->collection->unset($key);
76
    }
77
78
    /**
79
     * @see TableInterface::keys()
80
     */
81 1
    public function keys(): array
82
    {
83 1
        return $this->collection->keys();
84
    }
85
86
    /**
87
     * @see TableInterface::values()
88
     */
89 1
    public function values(): array
90
    {
91 1
        return $this->collection->values();
92
    }
93
94
    /**
95
     * @see TableInterface::&offsetGet($offset)
96
     */
97
    #[\ReturnTypeWillChange]
98 1
    public function &offsetGet($offset)
99
    {
100 1
        return $this->collection[$offset];
101
    }
102
103
    /**
104
     * @see TableInterface::offsetExists()
105
     */
106 1
    public function offsetExists($offset): bool
107
    {
108 1
        return isset($this->collection[$offset]);
109
    }
110
111
    /**
112
     * @see TableInterface::offsetSet()
113
     */
114 1
    public function offsetSet($offset, $value): void
115
    {
116 1
        $this->collection[$offset] = $value;
117 1
    }
118
119
    /**
120
     * @see TableInterface::offsetUnset()
121
     */
122 1
    public function offsetUnset($offset): void
123
    {
124 1
        unset($this->collection[$offset]);
125 1
    }
126
}
127