| Total Complexity | 11 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| 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) |
||
| 13 | { |
||
| 14 | $this->extradata = []; |
||
| 15 | foreach ($data as $d) { |
||
| 16 | $this->extradata[] = ($d instanceof Extradata) ? $d : Extradata::getFromData(null, $d); |
||
| 17 | } |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * All extradata objects. Yeah, that's a horrible plural, I know. |
||
| 22 | * |
||
| 23 | * @return Extradata[] |
||
| 24 | */ |
||
| 25 | public function getExtradatas(): array |
||
| 26 | { |
||
| 27 | return $this->extradata; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getExtradataSerialize(): array |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param string $name |
||
| 53 | * @return Extradata |
||
| 54 | */ |
||
| 55 | public function getExtradata(string $name) |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param string $name |
||
| 67 | * @param string $parameter |
||
| 68 | * @param Mixed $default |
||
| 69 | * @return Mixed |
||
| 70 | */ |
||
| 71 | public function getExtradataValue(string $name, string $parameter, $default = null) |
||
| 72 | { |
||
| 73 | $e = $this->getExtradata($name); |
||
| 74 | if (!$e) { |
||
|
|
|||
| 75 | return $default; |
||
| 76 | } |
||
| 77 | return $e->value($parameter, $default); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function appendExtradata(Extradata $m): self |
||
| 84 | } |
||
| 85 | } |
||
| 86 |