Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Address | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
| toArray | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| unserialize | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package Modules\Admin\Models |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace Modules\Admin\Models; |
| 16 | |
| 17 | use phpOMS\Stdlib\Base\Location; |
| 18 | |
| 19 | /** |
| 20 | * Address model |
| 21 | * |
| 22 | * @package Modules\Admin\Models |
| 23 | * @license OMS License 2.0 |
| 24 | * @link https://jingga.app |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | class Address extends Location |
| 28 | { |
| 29 | /** |
| 30 | * Name. |
| 31 | * |
| 32 | * @var string |
| 33 | * @since 1.0.0 |
| 34 | */ |
| 35 | public string $name = ''; |
| 36 | |
| 37 | /** |
| 38 | * Addition. |
| 39 | * |
| 40 | * @var string |
| 41 | * @since 1.0.0 |
| 42 | */ |
| 43 | public string $addition = ''; |
| 44 | |
| 45 | /** |
| 46 | * {@inheritdoc} |
| 47 | */ |
| 48 | public function toArray() : array |
| 49 | { |
| 50 | $data = parent::toArray(); |
| 51 | |
| 52 | $data['name'] = $this->name; |
| 53 | $data['addition'] = $this->addition; |
| 54 | |
| 55 | return $data; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * {@inheritdoc} |
| 60 | */ |
| 61 | public function jsonSerialize() : mixed |
| 62 | { |
| 63 | return $this->toArray(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * {@inheritdoc} |
| 68 | */ |
| 69 | public function serialize() : string |
| 70 | { |
| 71 | return (string) \json_encode($this->jsonSerialize()); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * {@inheritdoc} |
| 76 | */ |
| 77 | public function unserialize(mixed $serialized) : void |
| 78 | { |
| 79 | parent::unserialize($serialized); |
| 80 | |
| 81 | if (!\is_string($serialized)) { |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | /** @var array{name:string, addition:string} $data */ |
| 86 | $data = \json_decode($serialized, true); |
| 87 | if (!\is_array($data)) { |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | $this->name = $data['name']; |
| 92 | $this->addition = $data['addition']; |
| 93 | } |
| 94 | } |