Lines
100.00%
19 / 19
Functions and Methods
100.00%
4 / 4
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ThinnedContact | 100.00% | 19 / 19 | 100.00% | 4 / 4 | 4 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 1 | |||||
| ensureValid | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| toArray | 100.00% | 9 / 9 | 100.00% | 1 / 1 | 1 | |||||
| jsonSerialize | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace BO\Zmscitizenapi\Models; | |
| 6 | ||
| 7 | use BO\Zmsentities\Schema\Entity; | |
| 8 | use InvalidArgumentException; | |
| 9 | ||
| 10 | class ThinnedContact extends Entity implements \JsonSerializable | |
| 11 | { | |
| 12 | public static $schema = 'citizenapi/thinnedContact.json'; | |
| 13 | public ?string $city; | |
| 14 | public ?string $country; | |
| 15 | public ?string $name; | |
| 16 | public ?string $postalCode; | |
| 17 | public ?string $region; | |
| 18 | public ?string $street; | |
| 19 | public ?string $streetNumber; | |
| 20 | public function __construct(?string $city = null, ?string $country = null, ?string $name = null, ?string $postalCode = null, ?string $region = null, ?string $street = null, ?string $streetNumber = null) | |
| 21 | { | |
| 22 | $this->city = $city ?? ''; | |
| 23 | $this->country = $country ?? ''; | |
| 24 | $this->name = $name ?? ''; | |
| 25 | $this->postalCode = $postalCode ?? ''; | |
| 26 | $this->region = $region ?? ''; | |
| 27 | $this->street = $street ?? ''; | |
| 28 | $this->streetNumber = $streetNumber ?? ''; | |
| 29 | $this->ensureValid(); | |
| 30 | } | |
| 31 | ||
| 32 | private function ensureValid(): void | |
| 33 | { | |
| 34 | // testValid() is inherited from Entity; it checks $this against self::$schema. | |
| 35 | $this->testValid(); | |
| 36 | } | |
| 37 | ||
| 38 | public function toArray(): array | |
| 39 | { | |
| 40 | return [ | |
| 41 | 'city' => $this->city, | |
| 42 | 'country' => $this->country, | |
| 43 | 'name' => $this->name, | |
| 44 | 'postalCode' => $this->postalCode, | |
| 45 | 'region' => $this->region, | |
| 46 | 'street' => $this->street, | |
| 47 | 'streetNumber' => $this->streetNumber, | |
| 48 | ]; | |
| 49 | } | |
| 50 | ||
| 51 | #[\Override] | |
| 52 | public function jsonSerialize(): mixed | |
| 53 | { | |
| 54 | return $this->toArray(); | |
| 55 | } | |
| 56 | } |