Total Complexity | 10 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class ClassMappingView implements ClassMappingViewInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $type; |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | private $parameters = []; |
||
17 | |||
18 | /** |
||
19 | * @return string |
||
20 | */ |
||
21 | public function getType(): ?string |
||
22 | { |
||
23 | return $this->type; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $type |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function setType(string $type) |
||
31 | { |
||
32 | $this->type = $type; |
||
33 | return $this; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return array |
||
38 | */ |
||
39 | public function getParameters(): array |
||
42 | } |
||
43 | |||
44 | public function setParameter(string $parameter, $value): ClassMappingViewInterface |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param array $parameters |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function setParameters(array $parameters) |
||
58 | } |
||
59 | |||
60 | public static function merge(ClassMappingViewInterface ...$mappings): ClassMappingView |
||
61 | { |
||
62 | $target = new ClassMappingView(); |
||
63 | $parameters = []; |
||
64 | foreach ($mappings as $mapping) { |
||
65 | if ($mapping->getType()) { |
||
|
|||
66 | $target->setType($mapping->getType()); |
||
67 | } |
||
68 | foreach ($mapping->getParameters() as $parameter => $value) { |
||
69 | $parameters[$parameter] = $value; |
||
70 | } |
||
71 | } |
||
72 | $target->setParameters($parameters); |
||
73 | return $target; |
||
74 | } |
||
75 | |||
76 | public static function from(ClassMappingViewInterface $mapping): ClassMappingView |
||
79 | } |
||
80 | } |
||
81 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: