ProviderLocationFactory.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Factory\Location; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Entity\Location\ProviderLocation; |
| 6 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 7 | |
| 8 | /** |
| 9 | * Class ProviderLocationFactory |
| 10 | * |
| 11 | * @package AmeliaBooking\Domain\Factory\Location |
| 12 | */ |
| 13 | class ProviderLocationFactory |
| 14 | { |
| 15 | /** |
| 16 | * @param $data |
| 17 | * |
| 18 | * @return ProviderLocation |
| 19 | */ |
| 20 | public static function create($data) |
| 21 | { |
| 22 | $providerLocation = new ProviderLocation( |
| 23 | new Id($data['userId']), |
| 24 | new Id($data['locationId']) |
| 25 | ); |
| 26 | |
| 27 | if (isset($data['id'])) { |
| 28 | $providerLocation->setId(new Id($data['id'])); |
| 29 | } |
| 30 | |
| 31 | return $providerLocation; |
| 32 | } |
| 33 | } |
| 34 |