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