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