Passed
Push — master ( 414f0a...c0888e )
by Pierre
03:03
created

Simple::offsetExists()   A

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
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\Dictionary;
6
7
use Generator;
8
use Knp\DictionaryBundle\Dictionary;
9
10
/**
11
 * @template E
12
 * @implements Dictionary<E>
13
 */
14
final class Simple implements Dictionary
15
{
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
21
    /**
22
     * @var array<mixed, E>
23
     */
24
    private $values = [];
25
26
    /**
27
     * @param array<mixed, E> $values
28
     */
29 20
    public function __construct(string $name, array $values)
30
    {
31 20
        $this->name   = $name;
32 20
        $this->values = $values;
33 20
    }
34
35 13
    public function getName(): string
36
    {
37 13
        return $this->name;
38
    }
39
40 12
    public function getValues(): array
41
    {
42 12
        return $this->values;
43
    }
44
45 8
    public function getKeys(): array
46
    {
47 8
        return array_keys($this->values);
48
    }
49
50 1
    public function offsetExists($offset): bool
51
    {
52 1
        return \array_key_exists($offset, $this->values);
53
    }
54
55 2
    public function offsetGet($offset)
56
    {
57 2
        return $this->values[$offset];
58
    }
59
60 1
    public function offsetSet($offset, $value): void
61
    {
62 1
        $this->values[$offset] = $value;
63 1
    }
64
65 1
    public function offsetUnset($offset): void
66
    {
67 1
        unset($this->values[$offset]);
68 1
    }
69
70
    /**
71
     * @return Generator<mixed>
72
     */
73 1
    public function getIterator(): Generator
74
    {
75 1
        yield from $this->values;
76 1
    }
77
78 2
    public function count(): int
79
    {
80 2
        return \count($this->values);
81
    }
82
}
83