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 / Bookable / Service / PackageServiceFactory.php
ameliabooking / src / Domain / Factory / Bookable / Service Last commit date
CategoryFactory.php 2 years ago ExtraFactory.php 2 years ago PackageCustomerFactory.php 1 year ago PackageCustomerServiceFactory.php 1 year ago PackageFactory.php 1 year ago PackageServiceFactory.php 1 year ago ResourceFactory.php 1 year ago ServiceFactory.php 1 year ago
PackageServiceFactory.php
86 lines
1 <?php
2
3 /**
4 * @copyright © TMS-Plugins. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace AmeliaBooking\Domain\Factory\Bookable\Service;
9
10 use AmeliaBooking\Domain\Collection\Collection;
11 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
12 use AmeliaBooking\Domain\Entity\Bookable\Service\PackageService;
13 use AmeliaBooking\Domain\Factory\Location\LocationFactory;
14 use AmeliaBooking\Domain\Factory\User\UserFactory;
15 use AmeliaBooking\Domain\ValueObjects\BooleanValueObject;
16 use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger;
17 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
18 use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber;
19
20 /**
21 * Class PackageServiceFactory
22 *
23 * @package AmeliaBooking\Domain\Factory\Bookable\Service
24 */
25 class PackageServiceFactory
26 {
27 /**
28 * @param $data
29 *
30 * @return PackageService
31 * @throws InvalidArgumentException
32 */
33 public static function create($data)
34 {
35 /** @var PackageService $packageService */
36 $packageService = new PackageService();
37
38 if (isset($data['id'])) {
39 $packageService->setId(new Id($data['id']));
40 }
41
42 if (isset($data['quantity'])) {
43 $packageService->setQuantity(new PositiveInteger($data['quantity']));
44 }
45
46 if (isset($data['service'])) {
47 $packageService->setService(ServiceFactory::create($data['service']));
48 }
49
50 if (isset($data['minimumScheduled'])) {
51 $packageService->setMinimumScheduled(new WholeNumber($data['minimumScheduled']));
52 }
53
54 if (isset($data['maximumScheduled'])) {
55 $packageService->setMaximumScheduled(new WholeNumber($data['maximumScheduled']));
56 }
57
58 if (isset($data['allowProviderSelection'])) {
59 $packageService->setAllowProviderSelection(new BooleanValueObject($data['allowProviderSelection']));
60 }
61
62 $packageService->setProviders(new Collection());
63
64 if (!empty($data['providers'])) {
65 foreach ($data['providers'] as $providerData) {
66 $providerData['type'] = 'provider';
67 $packageService->getProviders()->addItem(UserFactory::create($providerData));
68 }
69 }
70
71 $packageService->setLocations(new Collection());
72
73 if (!empty($data['locations'])) {
74 foreach ($data['locations'] as $locationData) {
75 $packageService->getLocations()->addItem(LocationFactory::create($locationData));
76 }
77 }
78
79 if (!empty($data['position'])) {
80 $packageService->setPosition(new PositiveInteger($data['position']));
81 }
82
83 return $packageService;
84 }
85 }
86