Test Failed
Push — master ( 0864dc...48ec37 )
by Petr
12:45
created

ParameterInstances   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 32
c 0
b 0
f 0
dl 0
loc 50
rs 10

2 Methods

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