Simple   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 50
ccs 17
cts 17
cp 1
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A count() 0 3 1
A offsetSet() 0 3 1
A getIterator() 0 3 1
A __construct() 0 1 1
A getValues() 0 3 1
A offsetGet() 0 3 1
A getKeys() 0 3 1
A offsetUnset() 0 3 1
A getName() 0 3 1
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