ParameterInstances   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 32
dl 0
loc 50
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeys() 0 3 1
A getByKey() 0 6 2
1
<?php
2
3
namespace kalanis\Pohoda\PrintRequest;
4
5
use kalanis\PohodaException;
6
7
class ParameterInstances
8
{
9
    /** @var array<string, class-string<Parameter>> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, class-string<Parameter>> at position 4 could not be parsed: Unknown type name 'class-string' at position 4 in array<string, class-string<Parameter>>.
Loading history...
10
    protected array $instances = [
11
        'checkbox1' => Checkbox1::class,
12
        'checkbox2' => Checkbox2::class,
13
        'checkbox3' => Checkbox3::class,
14
        'checkbox4' => Checkbox4::class,
15
        'checkbox5' => Checkbox5::class,
16
        'checkbox6' => Checkbox6::class,
17
        'checkbox7' => Checkbox7::class,
18
        'checkbox8' => Checkbox8::class,
19
        'radioButton1' => RadioButton1::class,
20
        'spin1' => Spin1::class,
21
        'currency1' => Currency1::class,
22
        'month1' => Month1::class,
23
        'month2' => Month2::class,
24
        'year1' => Year1::class,
25
        'date1' => Date1::class,
26
        'date2' => Date2::class,
27
        'date3' => Date3::class,
28
        'date4' => Date4::class,
29
        'text1' => Text1::class,
30
        'text2' => Text2::class,
31
        'text3' => Text3::class,
32
        'combobox1' => Combobox1::class,
33
        'combobox2' => Combobox2::class,
34
        'combobox3' => Combobox3::class,
35
        'comboboxEx1' => ComboboxEx1::class,
36
        'comboboxEx2' => ComboboxEx2::class,
37
    ];
38
39
    /**
40
     * @param string $key
41
     * @return class-string<Parameter>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<Parameter> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<Parameter>.
Loading history...
42
     */
43 7
    public function getByKey(string $key): string
44
    {
45 7
        if (!isset($this->instances[$key])) {
46 1
            throw new PohodaException(sprintf('The key *%s* is not known.', $key));
47
        }
48 6
        return $this->instances[$key];
49
    }
50
51
    /**
52
     * @return string[]
53
     */
54 3
    public function getKeys(): array
55
    {
56 3
        return array_keys($this->instances);
57
    }
58
}
59