| @@ 44-56 (lines=13) @@ | ||
| 41 | 'taxRate' |
|
| 42 | ]; |
|
| 43 | ||
| 44 | public function __construct(array $data) |
|
| 45 | { |
|
| 46 | if (count(array_intersect_key(array_flip($this->requiredFields), $data)) !== count($this->requiredFields)) { |
|
| 47 | throw new InvalidArgumentException( |
|
| 48 | 'Cannot create object, required array keys: '. implode(', ', $this->requiredFields) |
|
| 49 | ); |
|
| 50 | } |
|
| 51 | ||
| 52 | // waiting for typed properties in PHP 7.4 |
|
| 53 | foreach ($data as $property => $value) { |
|
| 54 | $this->$property = $value; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getId(): string |
|
| 59 | { |
|
| @@ 36-48 (lines=13) @@ | ||
| 33 | 'cost', |
|
| 34 | ]; |
|
| 35 | ||
| 36 | public function __construct(array $data) |
|
| 37 | { |
|
| 38 | if (count(array_intersect_key(array_flip($this->requiredFields), $data)) !== count($this->requiredFields)) { |
|
| 39 | throw new InvalidArgumentException( |
|
| 40 | 'Cannot create object, required array keys: '. implode(', ', $this->requiredFields) |
|
| 41 | ); |
|
| 42 | } |
|
| 43 | ||
| 44 | // waiting for typed properties in PHP 7.4 |
|
| 45 | foreach ($data as $property => $value) { |
|
| 46 | $this->$property = $value; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | public function getId(): int |
|
| 51 | { |
|