| Total Complexity | 14 |
| Total Lines | 91 |
| Duplicated Lines | 0 % |
| Coverage | 55.56% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 5 | trait ExtradataTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var Extradata[] |
||
| 9 | */ |
||
| 10 | protected $extradata = []; |
||
| 11 | |||
| 12 | public function setExtradata(array $data): self |
||
| 13 | { |
||
| 14 | $this->extradata = []; |
||
| 15 | foreach ($data as $d) { |
||
| 16 | $this->extradata[] = ($d instanceof Extradata) ? $d : Extradata::getFromData(null, $d); |
||
| 17 | } |
||
| 18 | return $this; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * All extradata objects. Yeah, that's a horrible plural, I know. |
||
| 23 | * |
||
| 24 | * @return Extradata[] |
||
| 25 | */ |
||
| 26 | public function getExtradatas(): array |
||
| 27 | { |
||
| 28 | return $this->extradata; |
||
| 29 | } |
||
| 30 | |||
| 31 | 1 | public function getExtradataSerialize(): array |
|
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param string $name |
||
| 54 | * @return Extradata|null |
||
| 55 | */ |
||
| 56 | 1 | public function getExtradata(string $name): ?Extradata |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param string $name |
||
| 68 | * @param string $parameter |
||
| 69 | * @param Mixed $default |
||
| 70 | * @return Mixed |
||
| 71 | */ |
||
| 72 | 1 | public function getExtradataValue(string $name, string $parameter, $default = null) |
|
| 73 | { |
||
| 74 | 1 | $e = $this->getExtradata($name); |
|
| 75 | 1 | if (!$e) { |
|
| 76 | 1 | return $default; |
|
| 77 | } |
||
| 78 | 1 | return $e->value($parameter, $default); |
|
| 79 | } |
||
| 80 | |||
| 81 | public function appendExtradata(Extradata $m): self |
||
| 85 | } |
||
| 86 | |||
| 87 | public function removeExtraData(string $name): self |
||
| 98 |