Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.64% covered (warning)
63.64%
7 / 11
60.00% covered (warning)
60.00%
6 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
SimpleDictionary
63.64% covered (warning)
63.64%
7 / 11
60.00% covered (warning)
60.00%
6 / 10
14.81
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getValues
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getKeys
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetExists
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 offsetGet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetSet
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 offsetUnset
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIterator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 count
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22declare(strict_types=1);
23
24namespace App\Application\Dictionary;
25
26use Knp\DictionaryBundle\Dictionary as DictionaryInterface;
27
28class SimpleDictionary implements DictionaryInterface
29{
30    /**
31     * @var string
32     */
33    private $name;
34
35    /**
36     * @var array
37     */
38    private $values;
39
40    public function __construct(string $name, array $values)
41    {
42        $this->name   = $name;
43        $this->values = $values;
44    }
45
46    public function getName(): string
47    {
48        return $this->name;
49    }
50
51    public function getValues(): array
52    {
53        return $this->values;
54    }
55
56    public function getKeys(): array
57    {
58        return \array_keys($this->values);
59    }
60
61    public function offsetExists(mixed $offset): bool
62    {
63        return \array_key_exists($offset, $this->values);
64    }
65
66    public function offsetGet($offset): mixed
67    {
68        return $this->values[$offset];
69    }
70
71    public function offsetSet(mixed $offset, mixed $value): void
72    {
73        $this->values[$offset] = $value;
74    }
75
76    public function offsetUnset($offset): void
77    {
78        unset($this->values[$offset]);
79    }
80
81    public function getIterator(): \Traversable
82    {
83        return new \ArrayIterator($this->values);
84    }
85
86    public function count(): int
87    {
88        return count($this->values);
89    }
90}