Simple::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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