| @@ 17-120 (lines=104) @@ | ||
| 14 | /** |
|
| 15 | * @author Kasim Taskin <[email protected]> |
|
| 16 | */ |
|
| 17 | final class PaymentMethod implements CreatableFromArray |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $id; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | private $code; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var string |
|
| 31 | */ |
|
| 32 | private $name; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @var string |
|
| 36 | */ |
|
| 37 | private $description; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * PaymentMethod constructor. |
|
| 41 | */ |
|
| 42 | private function __construct( |
|
| 43 | int $id, |
|
| 44 | string $code, |
|
| 45 | string $name, |
|
| 46 | string $description |
|
| 47 | ) { |
|
| 48 | $this->id = $id; |
|
| 49 | $this->code = $code; |
|
| 50 | $this->name = $name; |
|
| 51 | $this->description = $description; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return ShipmentMethod |
|
| 56 | */ |
|
| 57 | public static function createFromArray(array $data): self |
|
| 58 | { |
|
| 59 | $id = -1; |
|
| 60 | if (isset($data['id'])) { |
|
| 61 | $id = $data['id']; |
|
| 62 | } |
|
| 63 | ||
| 64 | $code = ''; |
|
| 65 | if (isset($data['code'])) { |
|
| 66 | $code = $data['code']; |
|
| 67 | } |
|
| 68 | ||
| 69 | $name = ''; |
|
| 70 | if (isset($data['name'])) { |
|
| 71 | $name = $data['name']; |
|
| 72 | } |
|
| 73 | ||
| 74 | $description = ''; |
|
| 75 | if (isset($data['description'])) { |
|
| 76 | $description = $data['description']; |
|
| 77 | } |
|
| 78 | ||
| 79 | return new self($id, $code, $name, $description); |
|
| 80 | } |
|
| 81 | ||
| 82 | public function getId(): int |
|
| 83 | { |
|
| 84 | return $this->id; |
|
| 85 | } |
|
| 86 | ||
| 87 | public function getCode(): string |
|
| 88 | { |
|
| 89 | return $this->code; |
|
| 90 | } |
|
| 91 | ||
| 92 | public function getName(): string |
|
| 93 | { |
|
| 94 | return $this->name; |
|
| 95 | } |
|
| 96 | ||
| 97 | public function getDescription(): string |
|
| 98 | { |
|
| 99 | return $this->description; |
|
| 100 | } |
|
| 101 | } |
|
| 102 | ||
| @@ 17-117 (lines=101) @@ | ||
| 14 | /** |
|
| 15 | * @author Kasim Taskin <[email protected]> |
|
| 16 | */ |
|
| 17 | final class User implements CreatableFromArray |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $id; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | private $username; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var string[] |
|
| 31 | */ |
|
| 32 | private $roles; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @var bool |
|
| 36 | */ |
|
| 37 | private $enabled; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * User constructor. |
|
| 41 | * |
|
| 42 | * @param string[] $roles |
|
| 43 | */ |
|
| 44 | private function __construct(int $id, string $username, $roles, bool $enabled) |
|
| 45 | { |
|
| 46 | $this->id = $id; |
|
| 47 | $this->username = $username; |
|
| 48 | $this->roles = $roles; |
|
| 49 | $this->enabled = $enabled; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @return User |
|
| 54 | */ |
|
| 55 | public static function createFromArray(array $data): self |
|
| 56 | { |
|
| 57 | $id = -1; |
|
| 58 | ||
| 59 | if (isset($data['id'])) { |
|
| 60 | $id = $data['id']; |
|
| 61 | } |
|
| 62 | ||
| 63 | $username = ''; |
|
| 64 | if (isset($data['username'])) { |
|
| 65 | $username = $data['username']; |
|
| 66 | } |
|
| 67 | ||
| 68 | $roles = []; |
|
| 69 | if (isset($data['roles'])) { |
|
| 70 | $roles = $data['roles']; |
|
| 71 | } |
|
| 72 | ||
| 73 | $enabled = false; |
|
| 74 | if (isset($data['enabled'])) { |
|
| 75 | $enabled = $data['enabled']; |
|
| 76 | } |
|
| 77 | ||
| 78 | return new self($id, $username, $roles, $enabled); |
|
| 79 | } |
|
| 80 | ||
| 81 | public function getId(): int |
|
| 82 | { |
|
| 83 | return $this->id; |
|
| 84 | } |
|
| 85 | ||
| 86 | public function getUsername(): string |
|
| 87 | { |
|
| 88 | return $this->username; |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * @return string[] |
|
| 93 | */ |
|
| 94 | public function getRoles(): array |
|
| 95 | { |
|
| 96 | return $this->roles; |
|
| 97 | } |
|
| 98 | ||
| 99 | public function isEnabled(): bool |
|
| 100 | { |
|
| 101 | return $this->enabled; |
|
| 102 | } |
|
| 103 | } |
|
| 104 | ||
| @@ 17-120 (lines=104) @@ | ||
| 14 | /** |
|
| 15 | * @author Kasim Taskin <[email protected]> |
|
| 16 | */ |
|
| 17 | final class Variant implements CreatableFromArray |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $id; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | private $code; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var string[][] |
|
| 31 | */ |
|
| 32 | private $translations; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @var string[][] |
|
| 36 | */ |
|
| 37 | private $channelPricings; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Variant constructor. |
|
| 41 | * |
|
| 42 | * @param string[][] $translations |
|
| 43 | */ |
|
| 44 | private function __construct( |
|
| 45 | int $id, |
|
| 46 | string $code, |
|
| 47 | array $translations, |
|
| 48 | array $channelPricings |
|
| 49 | ) { |
|
| 50 | $this->id = $id; |
|
| 51 | $this->code = $code; |
|
| 52 | $this->translations = $translations; |
|
| 53 | $this->channelPricings = $channelPricings; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return Variant |
|
| 58 | */ |
|
| 59 | public static function createFromArray(array $data): self |
|
| 60 | { |
|
| 61 | $id = -1; |
|
| 62 | if (isset($data['id'])) { |
|
| 63 | $id = $data['id']; |
|
| 64 | } |
|
| 65 | ||
| 66 | $code = ''; |
|
| 67 | if (isset($data['code'])) { |
|
| 68 | $code = $data['code']; |
|
| 69 | } |
|
| 70 | ||
| 71 | $translations = []; |
|
| 72 | if (isset($data['translations'])) { |
|
| 73 | $translations = $data['translations']; |
|
| 74 | } |
|
| 75 | ||
| 76 | $channelPricings = []; |
|
| 77 | if (isset($data['channelPricings'])) { |
|
| 78 | $channelPricings = $data['channelPricings']; |
|
| 79 | } |
|
| 80 | ||
| 81 | return new self($id, $code, $translations, $channelPricings); |
|
| 82 | } |
|
| 83 | ||
| 84 | public function getId(): int |
|
| 85 | { |
|
| 86 | return $this->id; |
|
| 87 | } |
|
| 88 | ||
| 89 | public function getCode(): string |
|
| 90 | { |
|
| 91 | return $this->code; |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * @return \string[][] |
|
| 96 | */ |
|
| 97 | public function getTranslations(): array |
|
| 98 | { |
|
| 99 | return $this->translations; |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @return \string[][] |
|
| 104 | */ |
|
| 105 | public function getChannelPricings(): array |
|
| 106 | { |
|
| 107 | return $this->channelPricings; |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||