PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.27
Booking for Appointments and Events Calendar – Amelia v1.2.27
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Domain / Factory / Location / LocationFactory.php
ameliabooking / src / Domain / Factory / Location Last commit date
LocationFactory.php 1 year ago ProviderLocationFactory.php 1 year ago
LocationFactory.php
78 lines
1 <?php
2
3 namespace AmeliaBooking\Domain\Factory\Location;
4
5 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
6 use AmeliaBooking\Domain\Entity\Location\Location;
7 use AmeliaBooking\Domain\ValueObjects\Json;
8 use AmeliaBooking\Domain\ValueObjects\String\Status;
9 use AmeliaBooking\Domain\ValueObjects\Picture;
10 use AmeliaBooking\Domain\ValueObjects\String\Address;
11 use AmeliaBooking\Domain\ValueObjects\String\Description;
12 use AmeliaBooking\Domain\ValueObjects\GeoTag;
13 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
14 use AmeliaBooking\Domain\ValueObjects\String\Name;
15 use AmeliaBooking\Domain\ValueObjects\String\Phone;
16 use AmeliaBooking\Domain\ValueObjects\String\Url;
17
18 /**
19 * Class LocationFactory
20 *
21 * @package AmeliaBooking\Domain\Factory\Location
22 */
23 class LocationFactory
24 {
25 /**
26 * @param $data
27 *
28 * @return Location
29 * @throws InvalidArgumentException
30 */
31 public static function create($data)
32 {
33 $location = new Location();
34
35 if (isset($data['id'])) {
36 $location->setId(new Id($data['id']));
37 }
38
39 if (isset($data['name'])) {
40 $location->setName(new Name($data['name']));
41 }
42
43 if (isset($data['address'])) {
44 $location->setAddress(new Address($data['address']));
45 }
46
47 if (isset($data['phone'])) {
48 $location->setPhone(new Phone($data['phone']));
49 }
50
51 if (isset($data['latitude'], $data['longitude'])) {
52 $location->setCoordinates(new GeoTag($data['latitude'], $data['longitude']));
53 }
54
55 if (isset($data['description'])) {
56 $location->setDescription(new Description($data['description']));
57 }
58
59 if (isset($data['status'])) {
60 $location->setStatus(new Status($data['status']));
61 }
62
63 if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) {
64 $location->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath']));
65 }
66
67 if (isset($data['pin'])) {
68 $location->setPin(new Url($data['pin']));
69 }
70
71 if (!empty($data['translations'])) {
72 $location->setTranslations(new Json($data['translations']));
73 }
74
75 return $location;
76 }
77 }
78