| Total Complexity | 5 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | final class AentItemRegistry implements JsonPayloadInterface |
||
| 8 | { |
||
| 9 | /** @var string */ |
||
| 10 | private $name; |
||
| 11 | |||
| 12 | /** @var string */ |
||
| 13 | private $image; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * AentItemRegistry constructor. |
||
| 17 | * @param string $name |
||
| 18 | * @param string $image |
||
| 19 | */ |
||
| 20 | public function __construct(string $name, string $image) |
||
| 21 | { |
||
| 22 | $this->name = $name; |
||
| 23 | $this->image = $image; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return array<string,string> |
||
| 28 | */ |
||
| 29 | public function toArray(): array |
||
| 30 | { |
||
| 31 | return [ |
||
| 32 | 'NAME' => $this->getName(), |
||
| 33 | 'IMAGE' => $this->getImage(), |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param array $assoc |
||
| 39 | * @return AentItemRegistry |
||
| 40 | */ |
||
| 41 | public static function fromArray(array $assoc): self |
||
| 42 | { |
||
| 43 | $name = $assoc['NAME']; |
||
| 44 | $image = $assoc['IMAGE']; |
||
| 45 | return new self($name, $image); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getName(): string |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getImage(): string |
||
| 64 |