File manager - Edit - /home/premiey/www/wp-includes/images/media/Domain.tar
Back
Common/Exceptions/CouponExpiredException.php 0000666 00000000472 15165375612 0015313 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class CouponExpiredException * * @package AmeliaBooking\Domain\Common\Exceptions */ class CouponExpiredException extends \Exception { } Common/Exceptions/CouponUnknownException.php 0000666 00000000472 15165375612 0015352 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class CouponUnknownException * * @package AmeliaBooking\Domain\Common\Exceptions */ class CouponUnknownException extends \Exception { } Common/Exceptions/AuthorizationException.php 0000666 00000000472 15165375612 0015367 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class AuthorizationException * * @package AmeliaBooking\Domain\Common\Exceptions */ class AuthorizationException extends \Exception { } Common/Exceptions/CouponInvalidException.php 0000666 00000000472 15165375612 0015301 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class CouponInvalidException * * @package AmeliaBooking\Domain\Common\Exceptions */ class CouponInvalidException extends \Exception { } Common/Exceptions/BookingUnavailableException.php 0000666 00000000503 15165375612 0016256 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class BookingUnavailableException * * @package AmeliaBooking\Domain\Common\Exceptions */ class BookingUnavailableException extends \Exception { } Common/Exceptions/InvalidArgumentException.php 0000666 00000000476 15165375612 0015624 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class InvalidArgumentException * * @package AmeliaBooking\Domain\Common\Exceptions */ class InvalidArgumentException extends \Exception { } Common/Exceptions/ForbiddenFileUploadException.php 0000666 00000000506 15165375612 0016366 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class ForbiddenFileUploadException * * @package AmeliaBooking\Domain\Common\Exceptions */ class ForbiddenFileUploadException extends \Exception { } Common/Exceptions/EventBookingUnavailableException.php 0000666 00000000515 15165375612 0017263 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class EventBookingUnavailableException * * @package AmeliaBooking\Domain\Common\Exceptions */ class EventBookingUnavailableException extends \Exception { } Common/Exceptions/BookingCancellationException.php 0000666 00000000506 15165375612 0016432 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class BookingCancellationException * * @package AmeliaBooking\Domain\Common\Exceptions */ class BookingCancellationException extends \Exception { } Common/Exceptions/BookingsLimitReachedException.php 0000666 00000000507 15165375612 0016554 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class BookingsLimitReachedException * * @package AmeliaBooking\Domain\Common\Exceptions */ class BookingsLimitReachedException extends \Exception { } Common/Exceptions/CustomerBookedException.php 0000666 00000000474 15165375612 0015456 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class CustomerBookedException * * @package AmeliaBooking\Domain\Common\Exceptions */ class CustomerBookedException extends \Exception { } Common/Exceptions/PackageBookingUnavailableException.php 0000666 00000000522 15165375612 0017533 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Common\Exceptions; /** * Class PackageBookingUnavailableException * * @package AmeliaBooking\Domain\Common\Exceptions */ class PackageBookingUnavailableException extends \Exception { } Repository/User/CustomerRepositoryInterface.php 0000666 00000001066 15165375612 0016116 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\User; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CustomerRepositoryInterface * * @package AmeliaBooking\Domain\Repository\User */ interface CustomerRepositoryInterface extends BaseRepositoryInterface { /** * @param $criteria * @param int $itemsPerPage * * @return mixed */ public function getFiltered($criteria, $itemsPerPage); /** * @param $criteria * * @return mixed */ public function getCount($criteria); } Repository/User/ProviderRepositoryInterface.php 0000666 00000001272 15165375612 0016106 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\User; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface ProviderRepositoryInterface * * @package AmeliaBooking\Domain\Repository\User */ interface ProviderRepositoryInterface extends BaseRepositoryInterface { /** * @param $searchCriteria * * @return mixed */ public function getByCriteria($searchCriteria); /** * @param $criteria * @param int $itemsPerPage * * @return mixed */ public function getFiltered($criteria, $itemsPerPage); /** * @param $criteria * * @return mixed */ public function getCount($criteria); } Repository/User/UserRepositoryInterface.php 0000666 00000000765 15165375612 0015240 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\User; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface UserRepositoryInterface * * @package AmeliaBooking\Domain\Repository\User */ interface UserRepositoryInterface extends BaseRepositoryInterface { /** * @param int $id * * @return mixed */ public function findByExternalId($id); /** * @param $type * * @return mixed */ public function getAllByType($type); } Repository/Payment/PaymentRepositoryInterface.php 0000666 00000001001 15165375612 0016416 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Payment; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface PaymentRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Payment */ interface PaymentRepositoryInterface extends BaseRepositoryInterface { /** * @param int $status * * @return */ public function findByStatus($status); } Repository/Booking/Event/EventRepositoryInterface.php 0000666 00000000644 15165375612 0017132 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Booking\Event; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface AppointmentRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Booking\Event */ interface EventRepositoryInterface extends BaseRepositoryInterface { } Repository/Booking/Appointment/CustomerBookingExtraRepositoryInterface.php 0000666 00000000711 15165375612 0023377 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Booking\Appointment; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CustomerBookingExtraRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Booking\Appointment */ interface CustomerBookingExtraRepositoryInterface extends BaseRepositoryInterface { } Repository/Booking/Appointment/AppointmentRepositoryInterface.php 0000666 00000002326 15165375612 0021563 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException; /** * Interface AppointmentRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Booking\Appointment */ interface AppointmentRepositoryInterface extends BaseRepositoryInterface { /** * @param int $id * @param int $status * * @return mixed */ public function updateStatusById($id, $status); /** * @return array */ public function getCurrentAppointments(); /** * @param Collection $collection * @param array $providerIds * @param string $startDateTime * @param string $endDateTime * @return void * @throws QueryExecutionException */ public function getFutureAppointments($collection, $providerIds, $startDateTime, $endDateTime); /** * @param array $criteria * * @return mixed */ public function getFiltered($criteria); } Repository/Booking/Appointment/CustomerBookingRepositoryInterface.php 0000666 00000001352 15165375612 0022375 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Booking\Appointment; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CustomerBookingRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Booking\Appointment */ interface CustomerBookingRepositoryInterface extends BaseRepositoryInterface { /** * @param int $id * @param int $status * * @return mixed */ public function updateStatusById($id, $status); /** * @param int $id * @param int $status * * @return mixed */ public function updateStatusByAppointmentId($id, $status); } Repository/Coupon/CouponRepositoryInterface.php 0000666 00000000623 15165375612 0016103 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Coupon; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CouponRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Coupon */ interface CouponRepositoryInterface extends BaseRepositoryInterface { } Repository/CustomField/CustomFieldRepositoryInterface.php 0000666 00000000647 15165375612 0020037 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\CustomField; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CustomFieldRepositoryInterface * * @package AmeliaBooking\Domain\Repository\CustomField */ interface CustomFieldRepositoryInterface extends BaseRepositoryInterface { } Repository/CustomField/CustomFieldOptionRepositoryInterface.php 0000666 00000000663 15165375612 0021226 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\CustomField; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CustomFieldOptionRepositoryInterface * * @package AmeliaBooking\Domain\Repository\CustomField */ interface CustomFieldOptionRepositoryInterface extends BaseRepositoryInterface { } Repository/BaseRepositoryInterface.php 0000666 00000001576 15165375612 0014257 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository; /** * Interface BaseRepositoryInterface * * @package AmeliaBooking\Domain\Repository */ interface BaseRepositoryInterface { /** * @param int $id * * @return mixed */ public function getById($id); /** * @return mixed */ public function getAll(); /** * @param $entity * * @return mixed */ public function add($entity); /** * @param int $id * @param $entity * * @return mixed */ public function update($id, $entity); /** * @param $id * * @return mixed */ public function delete($id); /** * @return bool */ public function beginTransaction(); /** * @return bool */ public function commit(); /** * @return bool */ public function rollback(); } Repository/Gallery/GalleryRepositoryInterface.php 0000666 00000000626 15165375612 0016376 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Gallery; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface GalleryRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Gallery */ interface GalleryRepositoryInterface extends BaseRepositoryInterface { } Repository/Bookable/Service/CategoryRepositoryInterface.php 0000666 00000000476 15165375612 0020276 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\Bookable\Service; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface CategoryRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Bookable\Service */ interface CategoryRepositoryInterface extends BaseRepositoryInterface { } Repository/Bookable/Service/ServiceRepositoryInterface.php 0000666 00000001371 15165375612 0020114 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Repository\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface ServiceRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Bookable\Service */ interface ServiceRepositoryInterface extends BaseRepositoryInterface { /** * @param $serviceId * @param $userId * * @return Collection */ public function getProviderServicesWithExtras($serviceId, $userId); /** * @param $serviceId * * @return mixed */ public function getByIdWithExtras($serviceId); } Repository/Bookable/Service/ExtraRepositoryInterface.php 0000666 00000000467 15165375612 0017604 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\Bookable\Service; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface ExtraRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Bookable\Service */ interface ExtraRepositoryInterface extends BaseRepositoryInterface { } Repository/Location/LocationRepositoryInterface.php 0000666 00000001257 15165375612 0016721 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\Location; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface LocationRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Location */ interface LocationRepositoryInterface extends BaseRepositoryInterface { /** * @param $criteria * @param $itemsPerPage * * @return mixed */ public function getFiltered($criteria, $itemsPerPage); /** * @param $criteria * * @return mixed */ public function getCount($criteria); /** * @param $locationId * * @return mixed */ public function getServicesById($locationId); } Repository/Notification/NotificationRepositoryInterface.php 0000666 00000000476 15165375612 0020457 0 ustar 00 <?php namespace AmeliaBooking\Domain\Repository\Notification; use AmeliaBooking\Domain\Repository\BaseRepositoryInterface; /** * Interface NotificationRepositoryInterface * * @package AmeliaBooking\Domain\Repository\Notification */ interface NotificationRepositoryInterface extends BaseRepositoryInterface { } Events/DomainEventBus.php 0000666 00000002121 15165375612 0011417 0 ustar 00 <?php namespace AmeliaBooking\Domain\Events; use League\Event\Emitter; /** * Wrapper for the League Event library to keep the domain independent of infrastructure * Class DomainEventBus * * @package AmeliaBooking\Domain\Events */ class DomainEventBus { /** * Implementation of event emitter * * @var Emitter $eventEmitter */ private $eventEmitter; /** * Constructor with injection of event emitter implementation * * @param Emitter $eventEmitter */ public function __construct($eventEmitter) { $this->eventEmitter = $eventEmitter; } /** * Emitting the event through the Emitter * * @param $eventName * @param $eventParams */ public function emit($eventName, $eventParams) { $this->eventEmitter->emit($eventName, $eventParams); } /** * Adding an event listener * * @param $eventName * @param $subscriber */ public function addListener($eventName, $subscriber) { $this->eventEmitter->addListener($eventName, $subscriber); } } Events/User/UserChangedEvent.php 0000666 00000000133 15165375612 0012645 0 ustar 00 <?php /** * Created by PhpStorm. * User: alexander * Date: 9/19/17 * Time: 6:04 PM */ Entity/Zoom/ZoomMeeting.php 0000666 00000002664 15165375612 0011741 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Zoom; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class ZoomMeeting * * @package AmeliaBooking\Domain\Entity\Zoom */ class ZoomMeeting { /** @var Id */ private $id; /** @var Url */ private $joinUrl; /** @var Url */ private $startUrl; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Url */ public function getJoinUrl() { return $this->joinUrl; } /** * @param Url $joinUrl */ public function setJoinUrl(Url $joinUrl) { $this->joinUrl = $joinUrl; } /** * @return Url */ public function getStartUrl() { return $this->startUrl; } /** * @param Url $startUrl */ public function setStartUrl(Url $startUrl) { $this->startUrl = $startUrl; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'startUrl' => $this->getStartUrl() ? $this->getStartUrl()->getValue() : null, 'joinUrl' => $this->getJoinUrl() ? $this->getJoinUrl()->getValue() : null, ]; } } Entity/Notification/NotificationLog.php 0000666 00000007776 15165375612 0014307 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Notification; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class NotificationLog * * @package AmeliaBooking\Domain\Entity\Notification */ class NotificationLog { /** @var Id */ private $id; /** @var Id */ private $notificationsId; /** @var Id */ private $userId; /** @var Id */ private $appointmentId; /** @var Id */ private $eventId; /** @var Id */ private $packageCustomerId; /** @var DateTimeValue */ private $sentDateTime; /** @var BooleanValueObject */ private $sent; /** @var Json */ private $data; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getNotificationsId() { return $this->notificationsId; } /** * @param Id $notificationsId */ public function setNotificationsId($notificationsId) { $this->notificationsId = $notificationsId; } /** * @return Id */ public function getUserId() { return $this->userId; } /** * @param Id $userId */ public function setUserId($userId) { $this->userId = $userId; } /** * @return Id */ public function getAppointmentId() { return $this->appointmentId; } /** * @param Id $appointmentId */ public function setAppointmentId($appointmentId) { $this->appointmentId = $appointmentId; } /** * @return Id */ public function getEventId() { return $this->eventId; } /** * @param Id $eventId */ public function setEventId($eventId) { $this->eventId = $eventId; } /** * @return Id */ public function getPackageCustomerId() { return $this->packageCustomerId; } /** * @param Id $packageCustomerId */ public function setPackageCustomerId($packageCustomerId) { $this->packageCustomerId = $packageCustomerId; } /** * @return DateTimeValue */ public function getSentDateTime() { return $this->sentDateTime; } /** * @param DateTimeValue $sentDateTime */ public function setSentDateTime($sentDateTime) { $this->sentDateTime = $sentDateTime; } /** * @return BooleanValueObject */ public function getSent() { return $this->sent; } /** * @param BooleanValueObject $sent */ public function setSent($sent) { $this->sent = $sent; } /** * @return Json */ public function getData() { return $this->data; } /** * @param Json $data */ public function setData($data) { $this->data = $data; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'notificationId' => $this->getNotificationsId()->getValue(), 'userId' => $this->getUserId()->getValue(), 'appointmentId' => $this->getAppointmentId() ? $this->getAppointmentId()->getValue() : null, 'eventId' => $this->getEventId() ? $this->getEventId()->getValue() : null, 'packageCustomerId' => $this->getPackageCustomerId() ? $this->getPackageCustomerId()->getValue() : null, 'sentDateTime' => $this->getSentDateTime()->getValue(), 'sent' => $this->getSent() ? $this->getSent()->getValue() : null, 'data' => $this->getData() ? $this->getData()->getValue() : null, ]; } } Entity/Notification/Notification.php 0000666 00000017512 15165375612 0013632 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Notification; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\TimeOfDay; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Html; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo; use AmeliaBooking\Domain\ValueObjects\String\NotificationStatus; use AmeliaBooking\Domain\ValueObjects\String\NotificationType; /** * Class Notification * * @package AmeliaBooking\Domain\Entity\Notification */ class Notification { /** @var Id */ private $id; /** @var Name */ private $name; /** @var string */ private $customName; /** @var NotificationStatus */ private $status; /** @var TimeOfDay */ private $time; /** @var Duration */ private $timeBefore; /** @var Duration */ private $timeAfter; /** @var NotificationType */ private $type; /** @var NotificationSendTo */ private $sendTo; /** @var Name */ private $subject; /** @var Html */ private $content; /** @var BookingType */ private $entity; /** @var Json */ private $translations; /** @var array */ private $entityIds; /** @var BooleanValueObject */ private $sendOnlyMe; /** @var string */ private $whatsAppTemplate; /** * Notification constructor. * * @param Name $name * @param NotificationStatus $status * @param NotificationType $type * @param BookingType $entity * @param NotificationSendTo $sendTo * @param Name $subject * @param Html $content */ public function __construct( Name $name, NotificationStatus $status, NotificationType $type, BookingType $entity, NotificationSendTo $sendTo, Name $subject, Html $content ) { $this->name = $name; $this->status = $status; $this->type = $type; $this->entity = $entity; $this->sendTo = $sendTo; $this->subject = $subject; $this->content = $content; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return string */ public function getCustomName() { return $this->customName; } /** * @param string $customName */ public function setCustomName($customName) { $this->customName = $customName; } /** * @return NotificationStatus */ public function getStatus() { return $this->status; } /** * @param NotificationStatus $status */ public function setStatus(NotificationStatus $status) { $this->status = $status; } /** * @return NotificationType */ public function getType() { return $this->type; } /** * @param NotificationType $type */ public function setType(NotificationType $type) { $this->type = $type; } /** * @return BookingType */ public function getEntity() { return $this->entity; } /** * @param BookingType $entity */ public function setEntity(BookingType $entity) { $this->entity = $entity; } /** * @return TimeOfDay */ public function getTime() { return $this->time; } /** * @param TimeOfDay $time */ public function setTime($time) { $this->time = $time; } /** * @return Duration */ public function getTimeBefore() { return $this->timeBefore; } /** * @param Duration $timeBefore */ public function setTimeBefore($timeBefore) { $this->timeBefore = $timeBefore; } /** * @return Duration */ public function getTimeAfter() { return $this->timeAfter; } /** * @param Duration $timeAfter */ public function setTimeAfter($timeAfter) { $this->timeAfter = $timeAfter; } /** * @return NotificationSendTo */ public function getSendTo() { return $this->sendTo; } /** * @param NotificationSendTo $sendTo */ public function setSendTo(NotificationSendTo $sendTo) { $this->sendTo = $sendTo; } /** * @return Name */ public function getSubject() { return $this->subject; } /** * @param Name $subject */ public function setSubject(Name $subject) { $this->subject = $subject; } /** * @return Html */ public function getContent() { return $this->content; } /** * @param Html $content */ public function setContent(Html $content) { $this->content = $content; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function getEntityIds() { return $this->entityIds; } /** * @param array $entityIds */ public function setEntityIds($entityIds) { $this->entityIds = $entityIds; } /** * @return BooleanValueObject */ public function getSendOnlyMe() { return $this->sendOnlyMe; } /** * @param BooleanValueObject $sendOnlyMe */ public function setSendOnlyMe($sendOnlyMe) { $this->sendOnlyMe = $sendOnlyMe; } /** * @return string */ public function getWhatsAppTemplate() { return $this->whatsAppTemplate; } /** * @param string $whatsAppTemplate */ public function setWhatsAppTemplate($whatsAppTemplate) { $this->whatsAppTemplate = $whatsAppTemplate; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'name' => $this->getName()->getValue(), 'customName' => $this->getCustomName(), 'status' => $this->getStatus()->getValue(), 'type' => $this->getType()->getValue(), 'entity' => $this->getEntity()->getValue(), 'time' => null !== $this->getTime() ? $this->getTime()->getValue() : null, 'timeBefore' => null !== $this->getTimeBefore() ? $this->getTimeBefore()->getValue() : null, 'timeAfter' => null !== $this->getTimeAfter() ? $this->getTimeAfter()->getValue() : null, 'sendTo' => $this->getSendTo()->getValue(), 'subject' => $this->getSubject()->getValue(), 'content' => $this->getContent()->getValue(), 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, 'entityIds' => $this->getEntityIds(), 'sendOnlyMe' => $this->getSendOnlyMe() ? $this->getSendOnlyMe()->getValue() : null, 'whatsAppTemplate' => $this->getWhatsAppTemplate() ?: null, ]; } } Entity/Schedule/DayOff.php 0000666 00000005563 15165375612 0011465 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\DateRepeat; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class DayOff * * @package AmeliaBooking\Domain\Entity\Schedule */ class DayOff { /** @var Id */ private $id; /** @var Name */ private $name; /** @var DateTimeValue */ private $startDate; /** @var DateTimeValue */ private $endDate; /** @var DateRepeat */ private $repeat; /** * DayOff constructor. * * @param Name $name * @param DateTimeValue $startDate * @param DateTimeValue $endDate * @param DateRepeat $repeat */ public function __construct( Name $name, DateTimeValue $startDate, DateTimeValue $endDate, DateRepeat $repeat ) { $this->name = $name; $this->startDate = $startDate; $this->endDate = $endDate; $this->repeat = $repeat; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return DateTimeValue */ public function getStartDate() { return $this->startDate; } /** * @param DateTimeValue $startDate */ public function setStartDate(DateTimeValue $startDate) { $this->startDate = $startDate; } /** * @return DateTimeValue */ public function getEndDate() { return $this->endDate; } /** * @param DateTimeValue $endDate */ public function setEndDate(DateTimeValue $endDate) { $this->endDate = $endDate; } /** * @return DateRepeat */ public function getRepeat() { return $this->repeat; } /** * @param DateRepeat $repeat */ public function setRepeat(DateRepeat $repeat) { $this->repeat = $repeat; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->id ? $this->id->getValue() : null, 'name' => $this->name->getValue(), 'startDate' => $this->startDate->getValue()->format('Y-m-d'), 'endDate' => $this->endDate->getValue()->format('Y-m-d'), 'repeat' => $this->repeat->getValue(), ]; } } Entity/Schedule/PeriodLocation.php 0000666 00000002433 15165375612 0013221 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class PeriodLocation * * @package AmeliaBooking\Domain\Entity\Schedule */ class PeriodLocation { /** @var Id */ private $id; /** @var Id */ private $locationId; /** * PeriodLocation constructor. * * @param Id $locationId */ public function __construct( Id $locationId ) { $this->locationId = $locationId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'locationId' => $this->locationId->getValue(), ]; } } Entity/Schedule/TimeOut.php 0000666 00000003650 15165375612 0011676 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; /** * Class TimeOut * * @package AmeliaBooking\Domain\Entity\Schedule */ class TimeOut { /** @var Id */ private $id; /** @var DateTimeValue */ private $startTime; /** @var DateTimeValue */ private $endTime; /** * TimeOut constructor. * * @param DateTimeValue $startTime * @param DateTimeValue $endTime */ public function __construct( DateTimeValue $startTime, DateTimeValue $endTime ) { $this->startTime = $startTime; $this->endTime = $endTime; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return DateTimeValue */ public function getStartTime() { return $this->startTime; } /** * @param DateTimeValue $startTime */ public function setStartTime(DateTimeValue $startTime) { $this->startTime = $startTime; } /** * @return DateTimeValue */ public function getEndTime() { return $this->endTime; } /** * @param DateTimeValue $endTime */ public function setEndTime(DateTimeValue $endTime) { $this->endTime = $endTime; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'startTime' => $this->startTime->getValue()->format('H:i:s'), 'endTime' => $this->endTime->getValue()->format('H:i:s'), ]; } } Entity/Schedule/SpecialDayPeriod.php 0000666 00000007334 15165375612 0013474 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class SpecialDayPeriod * * @package AmeliaBooking\Domain\Entity\Schedule */ class SpecialDayPeriod { /** @var Id */ private $id; /** @var DateTimeValue */ private $startTime; /** @var DateTimeValue */ private $endTime; /** @var Id */ private $locationId; /** @var Collection */ private $periodServiceList; /** @var Collection */ private $periodLocationList; /** * SpecialDayPeriod constructor. * * @param DateTimeValue $startTime * @param DateTimeValue $endTime * @param Collection $periodServiceList * @param Collection $periodLocationList */ public function __construct( DateTimeValue $startTime, DateTimeValue $endTime, Collection $periodServiceList, Collection $periodLocationList ) { $this->startTime = $startTime; $this->endTime = $endTime; $this->periodServiceList = $periodServiceList; $this->periodLocationList = $periodLocationList; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return DateTimeValue */ public function getStartTime() { return $this->startTime; } /** * @param DateTimeValue $startTime */ public function setStartTime(DateTimeValue $startTime) { $this->startTime = $startTime; } /** * @return DateTimeValue */ public function getEndTime() { return $this->endTime; } /** * @param DateTimeValue $endTime */ public function setEndTime(DateTimeValue $endTime) { $this->endTime = $endTime; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return Collection */ public function getPeriodServiceList() { return $this->periodServiceList; } /** * @param Collection $periodServiceList */ public function setPeriodServiceList(Collection $periodServiceList) { $this->periodServiceList = $periodServiceList; } /** * @return Collection */ public function getPeriodLocationList() { return $this->periodLocationList; } /** * @param Collection $periodLocationList */ public function setPeriodLocationList(Collection $periodLocationList) { $this->periodLocationList = $periodLocationList; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'startTime' => $this->startTime->getValue()->format('H:i:s'), 'endTime' => $this->endTime->getValue()->format('H:i:s') === '00:00:00' ? '24:00:00' : $this->endTime->getValue()->format('H:i:s'), 'locationId' => $this->locationId ? $this->getLocationId()->getValue() : null, 'periodServiceList' => $this->periodServiceList->toArray(), 'periodLocationList' => $this->periodLocationList->toArray(), ]; } } Entity/Schedule/Period.php 0000666 00000007276 15165375612 0011542 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class Period * * @package AmeliaBooking\Domain\Entity\Schedule */ class Period { /** @var Id */ private $id; /** @var DateTimeValue */ private $startTime; /** @var DateTimeValue */ private $endTime; /** @var Id */ private $locationId; /** @var Collection */ private $periodServiceList; /** @var Collection */ private $periodLocationList; /** * Period constructor. * * @param DateTimeValue $startTime * @param DateTimeValue $endTime * @param Collection $periodServiceList * @param Collection $periodLocationList */ public function __construct( DateTimeValue $startTime, DateTimeValue $endTime, Collection $periodServiceList, Collection $periodLocationList ) { $this->startTime = $startTime; $this->endTime = $endTime; $this->periodServiceList = $periodServiceList; $this->periodLocationList = $periodLocationList; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return DateTimeValue */ public function getStartTime() { return $this->startTime; } /** * @param DateTimeValue $startTime */ public function setStartTime(DateTimeValue $startTime) { $this->startTime = $startTime; } /** * @return DateTimeValue */ public function getEndTime() { return $this->endTime; } /** * @param DateTimeValue $endTime */ public function setEndTime(DateTimeValue $endTime) { $this->endTime = $endTime; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return Collection */ public function getPeriodServiceList() { return $this->periodServiceList; } /** * @param Collection $periodServiceList */ public function setPeriodServiceList(Collection $periodServiceList) { $this->periodServiceList = $periodServiceList; } /** * @return Collection */ public function getPeriodLocationList() { return $this->periodLocationList; } /** * @param Collection $periodLocationList */ public function setPeriodLocationList(Collection $periodLocationList) { $this->periodLocationList = $periodLocationList; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'startTime' => $this->startTime->getValue()->format('H:i:s'), 'endTime' => $this->endTime->getValue()->format('H:i:s') === '00:00:00' ? '24:00:00' : $this->endTime->getValue()->format('H:i:s'), 'locationId' => $this->locationId ? $this->getLocationId()->getValue() : null, 'periodServiceList' => $this->periodServiceList->toArray(), 'periodLocationList' => $this->periodLocationList->toArray(), ]; } } Entity/Schedule/SpecialDay.php 0000666 00000004746 15165375612 0012335 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\Collection\Collection; /** * Class SpecialDay * * @package AmeliaBooking\Domain\Entity\Schedule */ class SpecialDay { /** @var Id */ private $id; /** @var DateTimeValue */ private $startDate; /** @var DateTimeValue */ private $endDate; /** @var Collection */ private $periodList; /** * SpecialDay constructor. * * @param DateTimeValue $startDate * @param DateTimeValue $endDate * @param Collection $periodList */ public function __construct( DateTimeValue $startDate, DateTimeValue $endDate, Collection $periodList ) { $this->startDate = $startDate; $this->endDate = $endDate; $this->periodList = $periodList; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return DateTimeValue */ public function getStartDate() { return $this->startDate; } /** * @param DateTimeValue $startDate */ public function setStartDate(DateTimeValue $startDate) { $this->startDate = $startDate; } /** * @return DateTimeValue */ public function getEndDate() { return $this->endDate; } /** * @param DateTimeValue $endDate */ public function setEndDate(DateTimeValue $endDate) { $this->endDate = $endDate; } /** * @return Collection */ public function getPeriodList() { return $this->periodList; } /** * @param Collection $periodList */ public function setPeriodList(Collection $periodList) { $this->periodList = $periodList; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'startDate' => $this->startDate->getValue()->format('Y-m-d'), 'endDate' => $this->endDate->getValue()->format('Y-m-d'), 'periodList' => $this->periodList->toArray(), ]; } } Entity/Schedule/WeekDay.php 0000666 00000007202 15165375612 0011636 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\Collection\Collection; /** * Class WeekDay * * @package AmeliaBooking\Domain\Entity\Schedule */ class WeekDay { /** @var Id */ private $id; /** @var IntegerValue */ private $dayIndex; /** @var DateTimeValue */ private $startTime; /** @var DateTimeValue */ private $endTime; /** @var Collection */ private $timeOutList; /** @var Collection */ private $periodList; /** * WeekDay constructor. * * @param IntegerValue $dayIndex * @param DateTimeValue $startTime * @param DateTimeValue $endTime * @param Collection $timeOutList * @param Collection $periodList */ public function __construct( IntegerValue $dayIndex, DateTimeValue $startTime, DateTimeValue $endTime, Collection $timeOutList, Collection $periodList ) { $this->dayIndex = $dayIndex; $this->startTime = $startTime; $this->endTime = $endTime; $this->timeOutList = $timeOutList; $this->periodList = $periodList; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return IntegerValue */ public function getDayIndex() { return $this->dayIndex; } /** * @param IntegerValue $dayIndex */ public function setDayIndex(IntegerValue $dayIndex) { $this->dayIndex = $dayIndex; } /** * @return DateTimeValue */ public function getStartTime() { return $this->startTime; } /** * @param DateTimeValue $startTime */ public function setStartTime(DateTimeValue $startTime) { $this->startTime = $startTime; } /** * @return DateTimeValue */ public function getEndTime() { return $this->endTime; } /** * @param DateTimeValue $endTime */ public function setEndTime(DateTimeValue $endTime) { $this->endTime = $endTime; } /** * @return Collection */ public function getTimeOutList() { return $this->timeOutList; } /** * @param Collection $timeOutList */ public function setTimeOutList(Collection $timeOutList) { $this->timeOutList = $timeOutList; } /** * @return Collection */ public function getPeriodList() { return $this->periodList; } /** * @param Collection $periodList */ public function setPeriodList(Collection $periodList) { $this->periodList = $periodList; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'dayIndex' => $this->dayIndex->getValue(), 'startTime' => $this->startTime->getValue()->format('H:i:s'), 'endTime' => $this->endTime->getValue()->format('H:i:s') === '00:00:00' ? '24:00:00' : $this->endTime->getValue()->format('H:i:s'), 'timeOutList' => $this->timeOutList->toArray(), 'periodList' => $this->periodList->toArray(), ]; } } Entity/Schedule/SpecialDayPeriodService.php 0000666 00000002514 15165375612 0015010 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class SpecialDayPeriodService * * @package AmeliaBooking\Domain\Entity\Schedule */ class SpecialDayPeriodService { /** @var Id */ private $id; /** @var Id */ private $serviceId; /** * SpecialDayPeriodService constructor. * * @param Id $serviceId */ public function __construct( Id $serviceId ) { $this->serviceId = $serviceId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getServiceId() { return $this->serviceId; } /** * @param Id $serviceId */ public function setServiceId(Id $serviceId) { $this->serviceId = $serviceId; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'serviceId' => $this->serviceId->getValue(), ]; } } Entity/Schedule/PeriodService.php 0000666 00000002411 15165375612 0013045 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class PeriodService * * @package AmeliaBooking\Domain\Entity\Schedule */ class PeriodService { /** @var Id */ private $id; /** @var Id */ private $serviceId; /** * PeriodService constructor. * * @param Id $serviceId */ public function __construct( Id $serviceId ) { $this->serviceId = $serviceId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getServiceId() { return $this->serviceId; } /** * @param Id $serviceId */ public function setServiceId(Id $serviceId) { $this->serviceId = $serviceId; } public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'serviceId' => $this->serviceId->getValue(), ]; } } Entity/Schedule/SpecialDayPeriodLocation.php 0000666 00000002536 15165375612 0015164 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Schedule; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class SpecialDayPeriodLocation * * @package AmeliaBooking\Domain\Entity\Schedule */ class SpecialDayPeriodLocation { /** @var Id */ private $id; /** @var Id */ private $locationId; /** * SpecialDayPeriodLocation constructor. * * @param Id $locationId */ public function __construct( Id $locationId ) { $this->locationId = $locationId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'locationId' => $this->locationId->getValue(), ]; } } Entity/Gallery/GalleryImage.php 0000666 00000006042 15165375612 0012513 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Gallery; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\EntityType; /** * Class GalleryImage * * @package AmeliaBooking\Domain\Entity\Gallery */ class GalleryImage { /** @var Id */ private $id; /** @var Id */ private $entityId; /** @var EntityType */ private $entityType; /** @var Picture */ private $picture; /** @var PositiveInteger */ protected $position; /** * GalleryImage constructor. * * @param EntityType $entityType * @param Picture $picture * @param PositiveInteger $position */ public function __construct( EntityType $entityType, Picture $picture, PositiveInteger $position ) { $this->entityType = $entityType; $this->picture = $picture; $this->position = $position; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getEntityId() { return $this->entityId; } /** * @param Id $entityId */ public function setEntityId(Id $entityId) { $this->entityId = $entityId; } /** * @return EntityType */ public function getEntityType() { return $this->entityType; } /** * @param EntityType $entityType */ public function setEntityType(EntityType $entityType) { $this->entityType = $entityType; } /** * @return Picture */ public function getPicture() { return $this->picture; } /** * @param Picture $picture */ public function setPicture(Picture $picture) { $this->picture = $picture; } /** * @return PositiveInteger */ public function getPosition() { return $this->position; } /** * @param PositiveInteger $position */ public function setPosition(PositiveInteger $position) { $this->position = $position; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'entityId' => null !== $this->getEntityId() ? $this->getEntityId()->getValue() : null, 'entityType' => null !== $this->getEntityType() ? $this->getEntityType()->getValue() : null, 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, 'position' => null !== $this->getPosition() ? $this->getPosition()->getValue() : null, ]; } } Entity/Outlook/OutlookCalendar.php 0000666 00000003507 15165375612 0013277 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Outlook; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class OutlookCalendar * * @package AmeliaBooking\Domain\Entity\Outlook */ class OutlookCalendar { /** @var Id */ private $id; /** @var Token */ private $token; /** @var Label */ private $calendarId; /** * OutlookCalendar constructor. * * @param Token $token * @param Label $calendarId */ public function __construct( Token $token, Label $calendarId ) { $this->token = $token; $this->calendarId = $calendarId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Token */ public function getToken() { return $this->token; } /** * @param Token $token */ public function setToken($token) { $this->token = $token; } /** * @return Label */ public function getCalendarId() { return $this->calendarId; } /** * @param Label $calendarId */ public function setCalendarId($calendarId) { $this->calendarId = $calendarId; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'token' => $this->getToken()->getValue(), 'calendarId' => null !== $this->getCalendarId() ? $this->getCalendarId()->getValue() : null, ]; } } Entity/Google/GoogleCalendar.php 0000666 00000003410 15165375612 0012630 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Google; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class GoogleCalendar * * @package AmeliaBooking\Domain\Entity\Google */ class GoogleCalendar { /** @var Id */ private $id; /** @var Token */ private $token; /** @var Name */ private $calendarId; /** * GoogleCalendar constructor. * * @param Token $token * @param Name $calendarId */ public function __construct( Token $token, Name $calendarId ) { $this->token = $token; $this->calendarId = $calendarId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Token */ public function getToken() { return $this->token; } /** * @param Token $token */ public function setToken($token) { $this->token = $token; } /** * @return Name */ public function getCalendarId() { return $this->calendarId; } /** * @param Name $calendarId */ public function setCalendarId($calendarId) { $this->calendarId = $calendarId; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'token' => $this->getToken()->getValue(), 'calendarId' => null !== $this->getCalendarId() ? $this->getCalendarId()->getValue() : null, ]; } } Entity/Settings/ZoomSettings.php 0000666 00000001313 15165375612 0013013 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class ZoomSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class ZoomSettings { /** @var bool */ private $enabled; /** * @return bool */ public function getEnabled() { return $this->enabled; } /** * @param bool $enabled */ public function setEnabled($enabled) { $this->enabled = $enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->getEnabled(), ]; } } Entity/Settings/PaymentMollieSettings.php 0000666 00000001120 15165375612 0014642 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentMollieSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentMollieSettings { /** @var bool */ private $enabled; /** * @return int */ public function getEnabled() { return $this->enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->enabled, ]; } } Entity/Settings/PaymentWooCommerceSettings.php 0000666 00000001132 15165375612 0015643 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentWooCommerceSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentWooCommerceSettings { /** @var bool */ private $enabled; /** * @return int */ public function getEnabled() { return $this->enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->enabled, ]; } } Entity/Settings/GeneralSettings.php 0000666 00000006562 15165375612 0013457 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class GeneralSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class GeneralSettings { /** @var int */ private $minimumTimeRequirementPriorToBooking; /** @var int */ private $minimumTimeRequirementPriorToCanceling; /** @var int */ private $minimumTimeRequirementPriorToRescheduling; /** @var string */ private $defaultAppointmentStatus; /** @var int */ private $numberOfDaysAvailableForBooking; /** * @return int */ public function getMinimumTimeRequirementPriorToBooking() { return $this->minimumTimeRequirementPriorToBooking; } /** * @param int $minimumTimeRequirementPriorToBooking */ public function setMinimumTimeRequirementPriorToBooking($minimumTimeRequirementPriorToBooking) { $this->minimumTimeRequirementPriorToBooking = $minimumTimeRequirementPriorToBooking; } /** * @return int */ public function getMinimumTimeRequirementPriorToCanceling() { return $this->minimumTimeRequirementPriorToCanceling; } /** * @param int $minimumTimeRequirementPriorToCanceling */ public function setMinimumTimeRequirementPriorToCanceling($minimumTimeRequirementPriorToCanceling) { $this->minimumTimeRequirementPriorToCanceling = $minimumTimeRequirementPriorToCanceling; } /** * @return int */ public function getMinimumTimeRequirementPriorToRescheduling() { return $this->minimumTimeRequirementPriorToRescheduling; } /** * @param int $minimumTimeRequirementPriorToRescheduling */ public function setMinimumTimeRequirementPriorToRescheduling($minimumTimeRequirementPriorToRescheduling) { $this->minimumTimeRequirementPriorToRescheduling = $minimumTimeRequirementPriorToRescheduling; } /** * @return string */ public function getDefaultAppointmentStatus() { return $this->defaultAppointmentStatus; } /** * @param string $defaultAppointmentStatus */ public function setDefaultAppointmentStatus($defaultAppointmentStatus) { $this->defaultAppointmentStatus = $defaultAppointmentStatus; } /** * @return int */ public function getNumberOfDaysAvailableForBooking() { return $this->numberOfDaysAvailableForBooking; } /** * @param int $numberOfDaysAvailableForBooking */ public function setNumberOfDaysAvailableForBooking($numberOfDaysAvailableForBooking) { $this->numberOfDaysAvailableForBooking = $numberOfDaysAvailableForBooking; } /** * @return array */ public function toArray() { return [ 'minimumTimeRequirementPriorToBooking' => $this->getMinimumTimeRequirementPriorToBooking(), 'minimumTimeRequirementPriorToCanceling' => $this->getMinimumTimeRequirementPriorToCanceling(), 'minimumTimeRequirementPriorToRescheduling' => $this->getMinimumTimeRequirementPriorToRescheduling(), 'defaultAppointmentStatus' => $this->getDefaultAppointmentStatus(), 'numberOfDaysAvailableForBooking' => $this->getNumberOfDaysAvailableForBooking(), ]; } } Entity/Settings/PaymentStripeSettings.php 0000666 00000001120 15165375612 0014667 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentStripeSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentStripeSettings { /** @var bool */ private $enabled; /** * @return int */ public function getEnabled() { return $this->enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->enabled, ]; } } Entity/Settings/LessonSpaceSettings.php 0000666 00000001331 15165375612 0014306 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class LessonSpaceSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class LessonSpaceSettings { /** @var bool */ private $enabled; /** * @return bool */ public function getEnabled() { return $this->enabled; } /** * @param bool $enabled */ public function setEnabled($enabled) { $this->enabled = $enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->getEnabled(), ]; } } Entity/Settings/PaymentPayPalSettings.php 0000666 00000001120 15165375612 0014607 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentPayPalSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentPayPalSettings { /** @var bool */ private $enabled; /** * @return int */ public function getEnabled() { return $this->enabled; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->enabled, ]; } } Entity/Settings/Settings.php 0000666 00000004126 15165375612 0012153 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class Settings * * @package AmeliaBooking\Domain\Entity\Settings */ class Settings { /** @var GeneralSettings */ private $generalSettings; /** @var PaymentSettings */ private $paymentSettings; /** @var ZoomSettings */ private $zoomSettings; /** @var LessonSpaceSettings */ private $lessonSpaceSettings; /** * @return GeneralSettings */ public function getGeneralSettings() { return $this->generalSettings; } /** * @param GeneralSettings $generalSettings */ public function setGeneralSettings($generalSettings) { $this->generalSettings = $generalSettings; } /** * @return PaymentSettings */ public function getPaymentSettings() { return $this->paymentSettings; } /** * @param PaymentSettings $paymentSettings */ public function setPaymentSettings($paymentSettings) { $this->paymentSettings = $paymentSettings; } /** * @return ZoomSettings */ public function getZoomSettings() { return $this->zoomSettings; } /** * @param ZoomSettings $zoomSettings */ public function setZoomSettings($zoomSettings) { $this->zoomSettings = $zoomSettings; } /** * @return LessonSpaceSettings */ public function getLessonSpaceSettings() { return $this->lessonSpaceSettings; } /** * @param LessonSpaceSettings $lessonSpaceSettings */ public function setLessonSpaceSettings($lessonSpaceSettings) { $this->lessonSpaceSettings = $lessonSpaceSettings; } /** * @return array */ public function toArray() { return [ 'general' => $this->getGeneralSettings() ? $this->getGeneralSettings()->toArray() : null, 'payments' => $this->getPaymentSettings() ? $this->getPaymentSettings()->toArray() : null, ]; } } Entity/Settings/PaymentSettings.php 0000666 00000006406 15165375612 0013514 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentSettings { /** @var bool */ private $onSite; /** @var PaymentPayPalSettings */ private $payPalSettings; /** @var PaymentStripeSettings */ private $stripeSettings; /** @var PaymentWooCommerceSettings */ private $wooCommerceSettings; /** @var PaymentMollieSettings */ private $mollieSettings; /** @var PaymentLinksSettings */ private $paymentLinksSettings; /** * @return bool */ public function getOnSite() { return $this->onSite; } /** * @param bool $onSite */ public function setOnSite($onSite) { $this->onSite = $onSite; } /** * @return PaymentPayPalSettings */ public function getPayPalSettings() { return $this->payPalSettings; } /** * @param PaymentPayPalSettings $payPalSettings */ public function setPayPalSettings($payPalSettings) { $this->payPalSettings = $payPalSettings; } /** * @return PaymentStripeSettings */ public function getStripeSettings() { return $this->stripeSettings; } /** * @param PaymentStripeSettings $stripeSettings */ public function setStripeSettings($stripeSettings) { $this->stripeSettings = $stripeSettings; } /** * @return PaymentWooCommerceSettings */ public function getWooCommerceSettings() { return $this->wooCommerceSettings; } /** * @param PaymentWooCommerceSettings $wooCommerceSettings */ public function setWooCommerceSettings($wooCommerceSettings) { $this->wooCommerceSettings = $wooCommerceSettings; } /** * @return PaymentMollieSettings */ public function getMollieSettings() { return $this->mollieSettings; } /** * @param PaymentMollieSettings $mollieSettings */ public function setMollieSettings($mollieSettings) { $this->mollieSettings = $mollieSettings; } /** * @return PaymentLinksSettings */ public function getPaymentLinksSettings() { return $this->paymentLinksSettings; } /** * @param PaymentLinksSettings $paymentLinksSettings */ public function setPaymentLinksSettings(PaymentLinksSettings $paymentLinksSettings) { $this->paymentLinksSettings = $paymentLinksSettings; } /** * @return array */ public function toArray() { return [ 'onSite' => $this->onSite, 'payPal' => $this->getPayPalSettings() ? $this->getPayPalSettings()->toArray() : null, 'stripe' => $this->getStripeSettings() ? $this->getStripeSettings()->toArray() : null, 'wc' => $this->getWooCommerceSettings() ? $this->getWooCommerceSettings()->toArray() : null, 'mollie' => $this->getMollieSettings() ? $this->getMollieSettings()->toArray() : null, 'paymentLinks' => $this->getPaymentLinksSettings() ? $this->getPaymentLinksSettings()->toArray() : null, ]; } } Entity/Settings/PaymentLinksSettings.php 0000666 00000002020 15165375612 0014501 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Settings; /** * Class PaymentLinksSettings * * @package AmeliaBooking\Domain\Entity\Settings */ class PaymentLinksSettings { /** @var bool */ private $enabled; /** @var bool */ private $changeBookingStatus; /** * @return bool */ public function getEnabled() { return $this->enabled; } /** * @return bool */ public function isChangeBookingStatus() { return $this->changeBookingStatus; } /** * @param bool $changeBookingStatus */ public function setChangeBookingStatus($changeBookingStatus) { $this->changeBookingStatus = $changeBookingStatus; } /** * @return array */ public function toArray() { return [ 'enabled' => $this->enabled, 'changeBookingStatus' => $this->changeBookingStatus ]; } } Entity/Bookable/AbstractCategory.php 0000666 00000006560 15165375612 0013536 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class AbstractCategory * * @package AmeliaBooking\Domain\Entity\Bookable */ abstract class AbstractCategory { /** @var Id */ private $id; /** @var Status */ protected $status; /** @var Name */ protected $name; /** @var Collection */ private $serviceList; /** @var PositiveInteger */ protected $position; /** @var Json */ protected $translations; /** * AbstractCategory constructor. * * @param Status $status * @param Name $name * @param PositiveInteger $position */ public function __construct( Status $status, Name $name, PositiveInteger $position ) { $this->status = $status; $this->name = $name; $this->position = $position; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return Collection */ public function getServiceList() { return $this->serviceList; } /** * @param Collection $serviceList */ public function setServiceList(Collection $serviceList) { $this->serviceList = $serviceList; } /** * @return PositiveInteger */ public function getPosition() { return $this->position; } /** * @param PositiveInteger $position */ public function setPosition($position) { $this->position = $position; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'status' => $this->getStatus()->getValue(), 'name' => $this->getName()->getValue(), 'serviceList' => $this->getServiceList() ? $this->getServiceList()->toArray() : [], 'position' => $this->getPosition()->getValue(), 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, ]; } } Entity/Bookable/Service/Extra.php 0000666 00000004577 15165375612 0012766 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Entity\Bookable\AbstractExtra; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Duration; /** * Class Extra * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class Extra extends AbstractExtra { /** @var Duration */ private $duration; /** @var Id */ private $serviceId; /** @var BooleanValueObject */ protected $aggregatedPrice; /** @var Json */ private $translations; /** * @return Duration */ public function getDuration() { return $this->duration; } /** * @param Duration $duration */ public function setDuration(Duration $duration) { $this->duration = $duration; } /** * @return Id */ public function getServiceId() { return $this->serviceId; } /** * @param Id $serviceId */ public function setServiceId(Id $serviceId) { $this->serviceId = $serviceId; } /** * @return BooleanValueObject */ public function getAggregatedPrice() { return $this->aggregatedPrice; } /** * @param BooleanValueObject $aggregatedPrice */ public function setAggregatedPrice(BooleanValueObject $aggregatedPrice) { $this->aggregatedPrice = $aggregatedPrice; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'duration' => $this->getDuration() ? $this->getDuration()->getValue() : null, 'serviceId' => $this->getServiceId() ? $this->getServiceId()->getValue() : null, 'aggregatedPrice' => $this->getAggregatedPrice() ? $this->getAggregatedPrice()->getValue() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, ] ); } } Entity/Bookable/Service/Resource.php 0000666 00000006676 15165375612 0013474 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class Resource * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class Resource { /** @var Id */ private $id; /** @var Name */ private $name; /** @var PositiveInteger */ private $quantity; /** @var EntityType */ private $shared; /** @var Status */ private $status; /** @var array */ private $entities; /** @var BooleanValueObject */ private $countAdditionalPeople; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName($name) { $this->name = $name; } /** * @return PositiveInteger */ public function getQuantity() { return $this->quantity; } /** * @param PositiveInteger $quantity */ public function setQuantity($quantity) { $this->quantity = $quantity; } /** * @return EntityType */ public function getShared() { return $this->shared; } /** * @param EntityType $shared */ public function setShared($shared) { $this->shared = $shared; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus($status) { $this->status = $status; } /** * @return array */ public function getEntities() { return $this->entities; } /** * @param array $entities */ public function setEntities($entities) { $this->entities = $entities; } /** * @return BooleanValueObject */ public function getCountAdditionalPeople() { return $this->countAdditionalPeople; } /** * @param BooleanValueObject $countAdditionalPeople */ public function setCountAdditionalPeople($countAdditionalPeople) { $this->countAdditionalPeople = $countAdditionalPeople; } /** * @return array */ public function toArray() { return [ 'id' => !empty($this->getId()) ? $this->getId()->getValue() : null, 'name' => !empty($this->getName()) ? $this->getName()->getValue() : '', 'quantity' => !empty($this->getQuantity()) ? $this->getQuantity()->getValue() : 1, 'shared' => !empty($this->getShared()) ? $this->getShared()->getValue() : false, 'status' => $this->getStatus()->getValue(), 'entities' => $this->getEntities(), 'countAdditionalPeople' => $this->getCountAdditionalPeople() ? $this->getCountAdditionalPeople()->getValue() : null ]; } } Entity/Bookable/Service/Service.php 0000666 00000026340 15165375612 0013273 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\Cycle; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Priority; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; /** * Class Service * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class Service extends AbstractBookable { /** @var IntegerValue */ private $minCapacity; /** @var IntegerValue */ private $maxCapacity; /** @var PositiveDuration */ private $duration; /** @var Duration */ private $timeBefore; /** @var Duration */ private $timeAfter; /** @var IntegerValue */ private $minSelectedExtras; /** @var BooleanValueObject */ private $bringingAnyone; /** @var BooleanValueObject */ private $mandatoryExtra; /** @var Priority */ private $priority; /** @var Collection */ private $gallery; /** @var Status */ protected $status; /** @var Id */ protected $categoryId; /** @var Category */ protected $category; /** @var BooleanValueObject */ protected $show; /** @var BooleanValueObject */ protected $aggregatedPrice; /** @var Cycle */ protected $recurringCycle; /** @var Name */ protected $recurringSub; /** @var WholeNumber */ protected $recurringPayment; /** @var Json */ protected $translations; /** @var Json */ protected $customPricing; /** @var IntegerValue */ private $maxExtraPeople; /** @var Json */ protected $limitPerCustomer; /** * @return Id */ public function getCategoryId() { return $this->categoryId; } /** * @param Id $categoryId */ public function setCategoryId(Id $categoryId) { $this->categoryId = $categoryId; } /** * @return Category */ public function getCategory() { return $this->category; } /** * @param Category $category */ public function setCategory(Category $category) { $this->category = $category; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return IntegerValue */ public function getMinCapacity() { return $this->minCapacity; } /** * @param IntegerValue $minCapacity */ public function setMinCapacity(IntegerValue $minCapacity) { $this->minCapacity = $minCapacity; } /** * @return IntegerValue */ public function getMaxCapacity() { return $this->maxCapacity; } /** * @param IntegerValue $maxCapacity */ public function setMaxCapacity(IntegerValue $maxCapacity) { $this->maxCapacity = $maxCapacity; } /** * @return PositiveDuration */ public function getDuration() { return $this->duration; } /** * @param PositiveDuration $duration */ public function setDuration(PositiveDuration $duration) { $this->duration = $duration; } /** * @return Duration */ public function getTimeBefore() { return $this->timeBefore; } /** * @param Duration $timeBefore */ public function setTimeBefore(Duration $timeBefore) { $this->timeBefore = $timeBefore; } /** * @return IntegerValue */ public function getMinSelectedExtras() { return $this->minSelectedExtras; } /** * @param IntegerValue $minSelectedExtras */ public function setMinSelectedExtras(IntegerValue $minSelectedExtras) { $this->minSelectedExtras = $minSelectedExtras; } /** * @return Duration */ public function getTimeAfter() { return $this->timeAfter; } /** * @param Duration $timeAfter */ public function setTimeAfter(Duration $timeAfter) { $this->timeAfter = $timeAfter; } /** * @return BooleanValueObject */ public function getBringingAnyone() { return $this->bringingAnyone; } /** * @param BooleanValueObject $bringingAnyone */ public function setBringingAnyone(BooleanValueObject $bringingAnyone) { $this->bringingAnyone = $bringingAnyone; } /** * @return BooleanValueObject */ public function getShow() { return $this->show; } /** * @param BooleanValueObject $show */ public function setShow(BooleanValueObject $show) { $this->show = $show; } /** * @return BooleanValueObject */ public function getAggregatedPrice() { return $this->aggregatedPrice; } /** * @param BooleanValueObject $aggregatedPrice */ public function setAggregatedPrice(BooleanValueObject $aggregatedPrice) { $this->aggregatedPrice = $aggregatedPrice; } /** * @return BooleanValueObject */ public function getMandatoryExtra() { return $this->mandatoryExtra; } /** * @param BooleanValueObject $mandatoryExtra */ public function setMandatoryExtra(BooleanValueObject $mandatoryExtra) { $this->mandatoryExtra = $mandatoryExtra; } /** * @return Priority */ public function getPriority() { return $this->priority; } /** * @param Priority $priority */ public function setPriority(Priority $priority) { $this->priority = $priority; } /** * @return Collection */ public function getGallery() { return $this->gallery; } /** * @param Collection $gallery */ public function setGallery(Collection $gallery) { $this->gallery = $gallery; } /** * @return Cycle */ public function getRecurringCycle() { return $this->recurringCycle; } /** * @param Cycle $recurringCycle */ public function setRecurringCycle(Cycle $recurringCycle) { $this->recurringCycle = $recurringCycle; } /** * @return Name */ public function getRecurringSub() { return $this->recurringSub; } /** * @param Name $recurringSub */ public function setRecurringSub(Name $recurringSub) { $this->recurringSub = $recurringSub; } /** * @return WholeNumber */ public function getRecurringPayment() { return $this->recurringPayment; } /** * @param WholeNumber $recurringPayment */ public function setRecurringPayment(WholeNumber $recurringPayment) { $this->recurringPayment = $recurringPayment; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return Json */ public function getCustomPricing() { return $this->customPricing; } /** * @param Json $customPricing */ public function setCustomPricing($customPricing) { $this->customPricing = $customPricing; } /** * @return IntegerValue */ public function getMaxExtraPeople() { return $this->maxExtraPeople; } /** * @param IntegerValue $maxExtraPeople */ public function setMaxExtraPeople($maxExtraPeople) { $this->maxExtraPeople = $maxExtraPeople; } /** * @return Json */ public function getLimitPerCustomer() { return $this->limitPerCustomer; } /** * @param Json $limitPerCustomer */ public function setLimitPerCustomer($limitPerCustomer) { $this->limitPerCustomer = $limitPerCustomer; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'minCapacity' => $this->getMinCapacity() ? $this->getMinCapacity()->getValue() : null, 'maxCapacity' => $this->getMaxCapacity() ? $this->getMaxCapacity()->getValue() : null, 'duration' => $this->getDuration() ? $this->getDuration()->getValue() : null, 'timeBefore' => $this->getTimeBefore() ? $this->getTimeBefore()->getValue() : null, 'timeAfter' => $this->getTimeAfter() ? $this->getTimeAfter()->getValue() : null, 'bringingAnyone' => $this->getBringingAnyone() ? $this->getBringingAnyone()->getValue() : null, 'show' => $this->getShow() ? $this->getShow()->getValue() : null, 'aggregatedPrice' => $this->getAggregatedPrice() ? $this->getAggregatedPrice()->getValue() : null, 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, 'categoryId' => $this->getCategoryId() ? $this->getCategoryId()->getValue() : null, 'category' => $this->getCategory() ? $this->getCategory()->toArray() : null, 'priority' => $this->getPriority() ? $this->getPriority()->getValue() : [], 'gallery' => $this->getGallery() ? $this->getGallery()->toArray() : [], 'recurringCycle' => $this->getRecurringCycle() ? $this->getRecurringCycle()->getValue() : null, 'recurringSub' => $this->getRecurringSub() ? $this->getRecurringSub()->getValue() : null, 'recurringPayment' => $this->getRecurringPayment() ? $this->getRecurringPayment()->getValue() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, 'minSelectedExtras'=> $this->getMinSelectedExtras() ? $this->getMinSelectedExtras()->getValue() : null, 'mandatoryExtra' => $this->getMandatoryExtra() ? $this->getMandatoryExtra()->getValue() : null, 'customPricing' => $this->getCustomPricing() ? $this->getCustomPricing()->getValue() : null, 'maxExtraPeople' => $this->getMaxExtraPeople() ? $this->getMaxExtraPeople()->getValue() : null, 'limitPerCustomer' => $this->getLimitPerCustomer() ? $this->getLimitPerCustomer()->getValue() : null, ] ); } } Entity/Bookable/Service/PackageCustomerService.php 0000666 00000006032 15165375612 0016265 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageCustomerService * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class PackageCustomerService { /** @var Id */ private $id; /** @var PackageCustomer */ private $packageCustomer; /** @var Id */ private $serviceId; /** @var Id */ private $providerId; /** @var Id */ private $locationId; /** @var WholeNumber */ private $bookingsCount; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getServiceId() { return $this->serviceId; } /** * @param Id $serviceId */ public function setServiceId(Id $serviceId) { $this->serviceId = $serviceId; } /** * @return Id */ public function getProviderId() { return $this->providerId; } /** * @param Id $providerId */ public function setProviderId(Id $providerId) { $this->providerId = $providerId; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return WholeNumber */ public function getBookingsCount() { return $this->bookingsCount; } /** * @param WholeNumber $bookingsCount */ public function setBookingsCount(WholeNumber $bookingsCount) { $this->bookingsCount = $bookingsCount; } /** * @return PackageCustomer */ public function getPackageCustomer() { return $this->packageCustomer; } /** * @param PackageCustomer $packageCustomer */ public function setPackageCustomer(PackageCustomer $packageCustomer) { $this->packageCustomer = $packageCustomer; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'serviceId' => $this->getServiceId() ? $this->getServiceId()->getValue() : null, 'providerId' => $this->getProviderId() ? $this->getProviderId()->getValue() : null, 'locationId' => $this->getLocationId() ? $this->getLocationId()->getValue() : null, 'bookingsCount' => $this->getBookingsCount() ? $this->getBookingsCount()->getValue() : null, 'packageCustomer' => $this->getPackageCustomer() ? $this->getPackageCustomer()->toArray() : null, ]; } } Entity/Bookable/Service/PackageCustomer.php 0000666 00000013205 15165375612 0014744 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\Entity\Coupon\Coupon; /** * Class PackageCustomer * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class PackageCustomer { /** @var Id */ private $id; /** @var Id */ private $packageId; /** @var Id */ private $customerId; /** @var Price */ private $price; /** @var DateTimeValue */ private $end; /** @var DateTimeValue */ private $start; /** @var DateTimeValue */ private $purchased; /** @var Collection */ private $payments; /** @var BookingStatus */ protected $status; /** @var WholeNumber */ private $bookingsCount; /** @var Id */ private $couponId; /** @var Coupon */ protected $coupon; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getPackageId() { return $this->packageId; } /** * @param Id $packageId */ public function setPackageId(Id $packageId) { $this->packageId = $packageId; } /** * @return Id */ public function getCustomerId() { return $this->customerId; } /** * @param Id $customerId */ public function setCustomerId(Id $customerId) { $this->customerId = $customerId; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return Collection */ public function getPayments() { return $this->payments; } /** * @param Collection $payments */ public function setPayments(Collection $payments) { $this->payments = $payments; } /** * @return DateTimeValue */ public function getEnd() { return $this->end; } /** * @param DateTimeValue $end */ public function setEnd(DateTimeValue $end) { $this->end = $end; } /** * @return DateTimeValue */ public function getStart() { return $this->start; } /** * @param DateTimeValue $start */ public function setStart(DateTimeValue $start) { $this->start = $start; } /** * @return DateTimeValue */ public function getPurchased() { return $this->purchased; } /** * @param DateTimeValue $purchased */ public function setPurchased(DateTimeValue $purchased) { $this->purchased = $purchased; } /** * @return BookingStatus */ public function getStatus() { return $this->status; } /** * @param BookingStatus $status */ public function setStatus(BookingStatus $status) { $this->status = $status; } /** * @return WholeNumber */ public function getBookingsCount() { return $this->bookingsCount; } /** * @param WholeNumber $bookingsCount */ public function setBookingsCount(WholeNumber $bookingsCount) { $this->bookingsCount = $bookingsCount; } /** * @return Id */ public function getCouponId() { return $this->couponId; } /** * @param Id $couponId */ public function setCouponId(Id $couponId) { $this->couponId = $couponId; } /** * @return Coupon */ public function getCoupon() { return $this->coupon; } /** * @param Coupon $coupon */ public function setCoupon(Coupon $coupon) { $this->coupon = $coupon; } /** * @return array */ public function toArray() { $dateTimeFormat = 'Y-m-d H:i:s'; return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'packageId' => $this->getPackageId() ? $this->getPackageId()->getValue() : null, 'customerId' => $this->getCustomerId() ? $this->getCustomerId()->getValue() : null, 'price' => $this->getPrice() ? $this->getPrice()->getValue() : null, 'payments' => $this->getPayments() ? $this->getPayments()->toArray() : null, 'start' => $this->getStart() ? $this->getStart()->getValue()->format($dateTimeFormat) : null, 'end' => $this->getEnd() ? $this->getEnd()->getValue()->format($dateTimeFormat) : null, 'purchased' => $this->getPurchased() ? $this->getPurchased()->getValue()->format($dateTimeFormat) : null, 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, 'bookingsCount' => $this->getBookingsCount() ? $this->getBookingsCount()->getValue() : null, 'couponId' => $this->getCouponId() ? $this->getCouponId()->getValue() : null, 'coupon' => $this->getCoupon() ? $this->getCoupon()->toArray() : null, ]; } } Entity/Bookable/Service/Package.php 0000666 00000015505 15165375612 0013227 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; /** * Class Package * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class Package extends AbstractBookable { /** @var Collection */ private $bookable; /** @var Collection */ private $gallery; /** @var Status */ protected $status; /** @var BooleanValueObject */ private $calculatedPrice; /** @var DiscountPercentageValue */ private $discount; /** @var DateTimeValue */ private $endDate; /** @var PositiveInteger */ private $durationCount; /** @var Label */ private $durationType; /** @var Json */ private $translations; /** @var BooleanValueObject */ private $sharedCapacity; /** @var PositiveInteger */ protected $quantity; /** @var Json */ protected $limitPerCustomer; /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return Collection */ public function getBookable() { return $this->bookable; } /** * @param Collection $bookable */ public function setBookable(Collection $bookable) { $this->bookable = $bookable; } /** * @return Collection */ public function getGallery() { return $this->gallery; } /** * @param Collection $gallery */ public function setGallery(Collection $gallery) { $this->gallery = $gallery; } /** * @return BooleanValueObject */ public function getCalculatedPrice() { return $this->calculatedPrice; } /** * @param BooleanValueObject $calculatedPrice */ public function setCalculatedPrice(BooleanValueObject $calculatedPrice) { $this->calculatedPrice = $calculatedPrice; } /** * @return DiscountPercentageValue */ public function getDiscount() { return $this->discount; } /** * @param DiscountPercentageValue $discount */ public function setDiscount(DiscountPercentageValue $discount) { $this->discount = $discount; } /** * @return PositiveInteger */ public function getDurationCount() { return $this->durationCount; } /** * @param PositiveInteger $durationCount */ public function setDurationCount(PositiveInteger $durationCount) { $this->durationCount = $durationCount; } /** * @return Label */ public function getDurationType() { return $this->durationType; } /** * @param Label $durationType */ public function setDurationType(Label $durationType) { $this->durationType = $durationType; } /** * @return DateTimeValue */ public function getEndDate() { return $this->endDate; } /** * @param DateTimeValue $endDate */ public function setEndDate(DateTimeValue $endDate) { $this->endDate = $endDate; } /** * @return BookingType */ public function getType() { return new Bookingtype(Entities::PACKAGE); } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return BooleanValueObject */ public function getSharedCapacity() { return $this->sharedCapacity; } /** * @param BooleanValueObject $sharedCapacity */ public function setSharedCapacity(BooleanValueObject $sharedCapacity) { $this->sharedCapacity = $sharedCapacity; } /** * @return PositiveInteger */ public function getQuantity() { return $this->quantity; } /** * @param PositiveInteger $quantity */ public function setQuantity(PositiveInteger $quantity) { $this->quantity = $quantity; } /** * @return Json */ public function getLimitPerCustomer() { return $this->limitPerCustomer; } /** * @param Json $limitPerCustomer */ public function setLimitPerCustomer($limitPerCustomer) { $this->limitPerCustomer = $limitPerCustomer; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'type' => $this->getType()->getValue(), 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, 'gallery' => $this->getGallery() ? $this->getGallery()->toArray() : [], 'bookable' => $this->getBookable() ? $this->getBookable()->toArray() : [], 'calculatedPrice' => $this->getCalculatedPrice() ? $this->getCalculatedPrice()->getValue() : null, 'discount' => $this->getDiscount() ? $this->getDiscount()->getValue() : null, 'endDate' => $this->getEndDate() ? $this->getEndDate()->getValue()->format('Y-m-d') . ' 00:00:00' : null, 'durationCount' => $this->getDurationCount() ? $this->getDurationCount()->getValue() : null, 'durationType' => $this->getDurationType() ? $this->getDurationType()->getValue() : null, 'position' => $this->getPosition() ? $this->getPosition()->getValue() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, 'sharedCapacity' => $this->getSharedCapacity() ? $this->getSharedCapacity()->getValue() : null, 'quantity' => $this->getQuantity() ? $this->getQuantity()->getValue() : null, 'limitPerCustomer' => $this->getLimitPerCustomer() ? $this->getLimitPerCustomer()->getValue() : null, ] ); } } Entity/Bookable/Service/PackageService.php 0000666 00000010513 15165375612 0014542 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageService * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class PackageService { /** @var Id */ private $id; /** @var Service */ protected $service; /** @var PositiveInteger */ protected $quantity; /** @var WholeNumber */ protected $minimumScheduled; /** @var WholeNumber */ protected $maximumScheduled; /** @var Collection */ private $providers; /** @var Collection */ private $locations; /** @var BooleanValueObject */ private $allowProviderSelection; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Service */ public function getService() { return $this->service; } /** * @param Service $service */ public function setService(Service $service) { $this->service = $service; } /** * @return PositiveInteger */ public function getQuantity() { return $this->quantity; } /** * @param PositiveInteger $quantity */ public function setQuantity(PositiveInteger $quantity) { $this->quantity = $quantity; } /** * @return WholeNumber */ public function getMinimumScheduled() { return $this->minimumScheduled; } /** * @param WholeNumber $minimumScheduled */ public function setMinimumScheduled(WholeNumber $minimumScheduled) { $this->minimumScheduled = $minimumScheduled; } /** * @return WholeNumber */ public function getMaximumScheduled() { return $this->maximumScheduled; } /** * @param WholeNumber $maximumScheduled */ public function setMaximumScheduled(WholeNumber $maximumScheduled) { $this->maximumScheduled = $maximumScheduled; } /** * @return Collection */ public function getProviders() { return $this->providers; } /** * @param Collection $providers */ public function setProviders(Collection $providers) { $this->providers = $providers; } /** * @return Collection */ public function getLocations() { return $this->locations; } /** * @param Collection $locations */ public function setLocations(Collection $locations) { $this->locations = $locations; } /** * @return BooleanValueObject */ public function getAllowProviderSelection() { return $this->allowProviderSelection; } /** * @param BooleanValueObject $allowProviderSelection */ public function setAllowProviderSelection($allowProviderSelection) { $this->allowProviderSelection = $allowProviderSelection; } /** * @return array */ public function toArray() { return array_merge( [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'quantity' => $this->getQuantity() ? $this->getQuantity()->getValue() : null, 'service' => $this->getService() ? $this->getService()->toArray() : null, 'minimumScheduled' => $this->getMinimumScheduled() ? $this->getMinimumScheduled()->getValue() : null, 'maximumScheduled' => $this->getMaximumScheduled() ? $this->getMaximumScheduled()->getValue() : null, 'providers' => $this->getProviders() ? $this->getProviders()->toArray() : [], 'locations' => $this->getLocations() ? $this->getLocations()->toArray() : [], 'allowProviderSelection' => $this->getAllowProviderSelection() ? $this->getAllowProviderSelection()->getValue() : null, ] ); } } Entity/Bookable/Service/Category.php 0000666 00000000377 15165375612 0013452 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Bookable\Service; use AmeliaBooking\Domain\Entity\Bookable\AbstractCategory; /** * Class Category * * @package AmeliaBooking\Domain\Entity\Bookable\Service */ class Category extends AbstractCategory { } Entity/Bookable/AbstractExtra.php 0000666 00000006577 15165375612 0013054 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Bookable; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class AbstractExtra * * @package AmeliaBooking\Domain\Entity\Bookable */ abstract class AbstractExtra { /** @var Id */ private $id; /** @var Name */ protected $name; /** @var Description */ protected $description; /** @var Price */ protected $price; /** @var PositiveInteger */ protected $maxQuantity; /** @var PositiveInteger */ protected $position; /** * @param Name $name * @param Description $description * @param Price $price * @param PositiveInteger $maxQuantity * @param PositiveInteger $position */ public function __construct( Name $name, Description $description, Price $price, PositiveInteger $maxQuantity, PositiveInteger $position ) { $this->name = $name; $this->description = $description; $this->price = $price; $this->maxQuantity = $maxQuantity; $this->position = $position; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return Description */ public function getDescription() { return $this->description; } /** * @param Description $description */ public function setDescription(Description $description) { $this->description = $description; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return PositiveInteger */ public function getMaxQuantity() { return $this->maxQuantity; } /** * @param PositiveInteger $maxQuantity */ public function setMaxQuantity(PositiveInteger $maxQuantity) { $this->maxQuantity = $maxQuantity; } /** * @return PositiveInteger */ public function getPosition() { return $this->position; } /** * @param PositiveInteger $position */ public function setPosition(PositiveInteger $position) { $this->position = $position; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'name' => $this->getName()->getValue(), 'description' => $this->getDescription()->getValue(), 'price' => $this->getPrice()->getValue(), 'maxQuantity' => $this->getMaxQuantity()->getValue(), 'position' => $this->getPosition()->getValue() ]; } } Entity/Bookable/AbstractBookable.php 0000666 00000015632 15165375612 0013477 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See COPYING.md for license details. */ namespace AmeliaBooking\Domain\Entity\Bookable; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class AbstractBookable * * @package AmeliaBooking\Domain\Entity\Bookable */ class AbstractBookable { /** @var Id */ private $id; /** @var Name */ protected $name; /** @var Description */ protected $description; /** @var Color */ protected $color; /** @var DepositType */ private $depositPayment; /** @var Price */ protected $deposit; /** @var BooleanValueObject */ protected $depositPerPerson; /** @var Price */ protected $price; /** @var Picture */ protected $picture; /** @var PositiveInteger */ protected $position; /** @var Collection */ private $extras; /** @var Collection */ private $coupons; /** @var Json */ private $settings; /** @var BooleanValueObject */ protected $fullPayment; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return Description */ public function getDescription() { return $this->description; } /** * @param Description $description */ public function setDescription(Description $description) { $this->description = $description; } /** * @return Color */ public function getColor() { return $this->color; } /** * @param Color $color */ public function setColor(Color $color) { $this->color = $color; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return Price */ public function getDeposit() { return $this->deposit; } /** * @param Price $deposit */ public function setDeposit(Price $deposit) { $this->deposit = $deposit; } /** * @return DepositType */ public function getDepositPayment() { return $this->depositPayment; } /** * @param DepositType $depositPayment */ public function setDepositPayment(DepositType $depositPayment) { $this->depositPayment = $depositPayment; } /** * @return BooleanValueObject */ public function getDepositPerPerson() { return $this->depositPerPerson; } /** * @param BooleanValueObject $depositPerPerson */ public function setDepositPerPerson(BooleanValueObject $depositPerPerson) { $this->depositPerPerson = $depositPerPerson; } /** * @return Picture */ public function getPicture() { return $this->picture; } /** * @param Picture $picture */ public function setPicture(Picture $picture) { $this->picture = $picture; } /** * @return PositiveInteger */ public function getPosition() { return $this->position; } /** * @param PositiveInteger $position */ public function setPosition($position) { $this->position = $position; } /** * @return Collection */ public function getExtras() { return $this->extras; } /** * @param Collection $extras */ public function setExtras(Collection $extras) { $this->extras = $extras; } /** * @return Collection */ public function getCoupons() { return $this->coupons; } /** * @param Collection $coupons */ public function setCoupons(Collection $coupons) { $this->coupons = $coupons; } /** * @return Json */ public function getSettings() { return $this->settings; } /** * @param Json $settings */ public function setSettings($settings) { $this->settings = $settings; } /** * @return BooleanValueObject */ public function getFullPayment() { return $this->fullPayment; } /** * @param BooleanValueObject $fullPayment */ public function setFullPayment(BooleanValueObject $fullPayment) { $this->fullPayment = $fullPayment; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'name' => null !== $this->getName() ? $this->getName()->getValue() : null, 'description' => null !== $this->getDescription() ? $this->getDescription()->getValue() : null, 'color' => null !== $this->getColor() ? $this->getColor()->getValue() : null, 'price' => $this->getPrice()->getValue(), 'deposit' => null !== $this->getDeposit() ? $this->getDeposit()->getValue() : null, 'depositPayment' => null !== $this->getDepositPayment() ? $this->getDepositPayment()->getValue() : null, 'depositPerPerson' => null !== $this->getDepositPerPerson() ? $this->getDepositPerPerson()->getValue() : null, 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, 'extras' => $this->getExtras() ? $this->getExtras()->toArray() : [], 'coupons' => $this->getCoupons() ? $this->getCoupons()->toArray() : [], 'position' => null !== $this->getPosition() ? $this->getPosition()->getValue() : null, 'settings' => null !== $this->getSettings() ? $this->getSettings()->getValue() : null, 'fullPayment' => null !== $this->getFullPayment() ? $this->getFullPayment()->getValue() : null, ]; } } Entity/Cache/Cache.php 0000666 00000004036 15165375612 0010561 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Cache; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class Cache * * @package AmeliaBooking\Domain\Entity\Cache */ class Cache { /** @var Id */ private $id; /** @var Name */ private $name; /** @var Id */ private $paymentId; /** @var Json */ protected $data; /** * Cache constructor. * * @param Name $name */ public function __construct( Name $name ) { $this->name = $name; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName($name) { $this->name = $name; } /** * @return Id */ public function getPaymentId() { return $this->paymentId; } /** * @param Id $paymentId */ public function setPaymentId($paymentId) { $this->paymentId = $paymentId; } /** * @return Json */ public function getData() { return $this->data; } /** * @param Json $data */ public function setData(Json $data) { $this->data = $data; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'name' => $this->getName()->getValue(), 'paymentId' => $this->getPaymentId() ? $this->getPaymentId()->getValue() : null, 'data' => $this->getData() ? $this->getData()->getValue() : null, ]; } } Entity/Coupon/Coupon.php 0000666 00000017113 15165375612 0011261 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Coupon; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountFixedValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\CouponCode; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class Coupon * * @package AmeliaBooking\Domain\Entity\Coupon */ class Coupon { /** @var Id */ private $id; /** @var CouponCode */ private $code; /** @var DiscountPercentageValue */ private $discount; /** @var DiscountFixedValue */ private $deduction; /** @var PositiveInteger */ private $limit; /** @var WholeNumber */ private $customerLimit; /** @var WholeNumber */ private $used; /** @var WholeNumber */ private $notificationInterval; /** @var BooleanValueObject */ private $notificationRecurring; /** @var Status */ private $status; /** @var Collection */ private $serviceList; /** @var Collection */ private $eventList; /** @var Collection */ private $packageList; /** @var DateTimeValue */ private $expirationDate; /** * Coupon constructor. * * @param CouponCode $code * @param DiscountPercentageValue $discount * @param DiscountFixedValue $deduction * @param PositiveInteger $limit * @param Status $status */ public function __construct( CouponCode $code, DiscountPercentageValue $discount, DiscountFixedValue $deduction, PositiveInteger $limit, Status $status ) { $this->code = $code; $this->discount = $discount; $this->deduction = $deduction; $this->limit = $limit; $this->status = $status; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return CouponCode */ public function getCode() { return $this->code; } /** * @param CouponCode $code */ public function setCode(CouponCode $code) { $this->code = $code; } /** * @return DiscountPercentageValue */ public function getDiscount() { return $this->discount; } /** * @param DiscountPercentageValue $discount */ public function setDiscount(DiscountPercentageValue $discount) { $this->discount = $discount; } /** * @return DiscountFixedValue */ public function getDeduction() { return $this->deduction; } /** * @param DiscountFixedValue $deduction */ public function setDeduction(DiscountFixedValue $deduction) { $this->deduction = $deduction; } /** * @return PositiveInteger */ public function getLimit() { return $this->limit; } /** * @param PositiveInteger $limit */ public function setLimit($limit) { $this->limit = $limit; } /** * @return WholeNumber */ public function getCustomerLimit() { return $this->customerLimit; } /** * @param WholeNumber $customerLimit */ public function setCustomerLimit($customerLimit) { $this->customerLimit = $customerLimit; } /** * @return WholeNumber */ public function getUsed() { return $this->used; } /** * @param WholeNumber $used */ public function setUsed($used) { $this->used = $used; } /** * @return WholeNumber */ public function getNotificationInterval() { return $this->notificationInterval; } /** * @param WholeNumber $notificationInterval */ public function setNotificationInterval($notificationInterval) { $this->notificationInterval = $notificationInterval; } /** * @return BooleanValueObject */ public function getNotificationRecurring() { return $this->notificationRecurring; } /** * @param BooleanValueObject $notificationRecurring */ public function setNotificationRecurring($notificationRecurring) { $this->notificationRecurring = $notificationRecurring; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return Collection */ public function getServiceList() { return $this->serviceList; } /** * @param Collection $serviceList */ public function setServiceList(Collection $serviceList) { $this->serviceList = $serviceList; } /** * @return Collection */ public function getEventList() { return $this->eventList; } /** * @param Collection $eventList */ public function setEventList(Collection $eventList) { $this->eventList = $eventList; } /** * @return Collection */ public function getPackageList() { return $this->packageList; } /** * @param Collection $packageList */ public function setPackageList(Collection $packageList) { $this->packageList = $packageList; } /** * @return DateTimeValue */ public function getExpirationDate() { return $this->expirationDate; } /** * @param DateTimeValue $expirationDate */ public function setExpirationDate(DateTimeValue $expirationDate) { $this->expirationDate = $expirationDate; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'code' => $this->getCode()->getValue(), 'discount' => $this->getDiscount()->getValue(), 'deduction' => $this->getDeduction()->getValue(), 'limit' => $this->getLimit()->getValue(), 'customerLimit' => $this->getCustomerLimit()->getValue(), 'used' => $this->getUsed() ? $this->getUsed()->getValue() : 0, 'notificationInterval' => $this->getNotificationInterval() ? $this->getNotificationInterval()->getValue() : 0, 'notificationRecurring' => $this->getNotificationRecurring() ? $this->getNotificationRecurring()->getValue() : 0, 'status' => $this->getStatus()->getValue(), 'serviceList' => $this->getServiceList() ? $this->getServiceList()->toArray() : [], 'eventList' => $this->getEventList() ? $this->getEventList()->toArray() : [], 'packageList' => $this->getPackageList() ? $this->getPackageList()->toArray() : [], 'expirationDate' => $this->getExpirationDate() ? $this->getExpirationDate()->getValue()->format('Y-m-d') : null, ]; } } Entity/CustomField/CustomField.php 0000666 00000013027 15165375612 0013207 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\CustomField; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\CustomFieldType; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomField * * @package AmeliaBooking\Domain\Entity\CustomField */ class CustomField { /** @var Id */ private $id; /** @var Label */ private $label; /** @var CustomFieldType */ private $type; /** @var BooleanValueObject */ private $required; /** @var IntegerValue */ private $position; /** @var Json */ private $translations; /** @var Collection */ private $options; /** @var Collection */ private $services; /** @var Collection */ private $events; /** @var BooleanValueObject */ private $allServices; /** @var BooleanValueObject */ private $allEvents; /** * CustomField constructor. * * @param Label $label * @param CustomFieldType $type * @param BooleanValueObject $required * @param IntegerValue $position */ public function __construct( Label $label, CustomFieldType $type, BooleanValueObject $required, IntegerValue $position ) { $this->label = $label; $this->type = $type; $this->required = $required; $this->position = $position; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Label */ public function getLabel() { return $this->label; } /** * @param Label $label */ public function setLabel($label) { $this->label = $label; } /** * @return CustomFieldType */ public function getType() { return $this->type; } /** * @param CustomFieldType $type */ public function setType($type) { $this->type = $type; } /** * @return BooleanValueObject */ public function getRequired() { return $this->required; } /** * @param BooleanValueObject $required */ public function setRequired($required) { $this->required = $required; } /** * @return IntegerValue */ public function getPosition() { return $this->position; } /** * @param IntegerValue $position */ public function setPosition($position) { $this->position = $position; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return Collection */ public function getOptions() { return $this->options; } /** * @param Collection $options */ public function setOptions($options) { $this->options = $options; } /** * @return Collection */ public function getServices() { return $this->services; } /** * @param Collection $services */ public function setServices($services) { $this->services = $services; } /** * @return Collection */ public function getEvents() { return $this->events; } /** * @param Collection $events */ public function setEvents($events) { $this->events = $events; } /** * @return BooleanValueObject */ public function getAllServices() { return $this->allServices; } /** * @param BooleanValueObject $allServices */ public function setAllServices($allServices) { $this->allServices = $allServices; } /** * @return BooleanValueObject */ public function getAllEvents() { return $this->allEvents; } /** * @param BooleanValueObject $allEvents */ public function setAllEvents($allEvents) { $this->allEvents = $allEvents; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'label' => $this->getLabel()->getValue(), 'type' => $this->getType()->getValue(), 'required' => $this->getRequired()->getValue(), 'position' => $this->getPosition()->getValue(), 'options' => $this->getOptions() ? $this->getOptions()->toArray() : [], 'services' => $this->getServices() ? $this->getServices()->toArray() : [], 'events' => $this->getEvents() ? $this->getEvents()->toArray() : [], 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, 'allServices' => $this->getAllServices() ? $this->getAllServices()->getValue() : null, 'allEvents' => $this->getAllEvents() ? $this->getAllEvents()->getValue() : null, ]; } } Entity/CustomField/CustomFieldOption.php 0000666 00000005534 15165375612 0014404 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\CustomField; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomFieldOption * * @package AmeliaBooking\Domain\Entity\CustomField */ class CustomFieldOption { /** @var Id */ private $id; /** @var Id */ private $customFieldId; /** @var Label */ private $label; /** @var IntegerValue */ private $position; /** @var Json */ private $translations; /** * CustomFieldOption constructor. * * @param Id $customFieldId * @param Label $label * @param IntegerValue $position */ public function __construct(Id $customFieldId, Label $label, IntegerValue $position) { $this->customFieldId = $customFieldId; $this->label = $label; $this->position = $position; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Id */ public function getCustomFieldId() { return $this->customFieldId; } /** * @param Id $customFieldId */ public function setCustomFieldId($customFieldId) { $this->customFieldId = $customFieldId; } /** * @return Label */ public function getLabel() { return $this->label; } /** * @param Label $label */ public function setLabel($label) { $this->label = $label; } /** * @return IntegerValue */ public function getPosition() { return $this->position; } /** * @param IntegerValue $position */ public function setPosition($position) { $this->position = $position; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'customFieldId' => $this->getCustomFieldId()->getValue(), 'label' => $this->getLabel()->getValue(), 'position' => $this->getPosition()->getValue(), 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, ]; } } Entity/Booking/Event/EventPeriod.php 0000666 00000011744 15165375612 0013454 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\Entity\Zoom\ZoomMeeting; use AmeliaBooking\Domain\ValueObjects\String\Token; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class EventPeriod * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class EventPeriod { /** @var Id */ private $id; /** @var Id */ private $eventId; /** @var DateTimeValue */ protected $periodStart; /** @var DateTimeValue */ protected $periodEnd; /** @var ZoomMeeting */ private $zoomMeeting; /** @var string */ private $lessonSpace; /** @var Collection */ protected $bookings; /** @var Token */ private $googleCalendarEventId; /** @var string */ private $googleMeetUrl; /** @var Label */ private $outlookCalendarEventId; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getEventId() { return $this->eventId; } /** * @param Id $eventId */ public function setEventId(Id $eventId) { $this->eventId = $eventId; } /** * @return DateTimeValue */ public function getPeriodStart() { return $this->periodStart; } /** * @param DateTimeValue $periodStart */ public function setPeriodStart(DateTimeValue $periodStart) { $this->periodStart = $periodStart; } /** * @return DateTimeValue */ public function getPeriodEnd() { return $this->periodEnd; } /** * @param DateTimeValue $periodEnd */ public function setPeriodEnd(DateTimeValue $periodEnd) { $this->periodEnd = $periodEnd; } /** * @return ZoomMeeting */ public function getZoomMeeting() { return $this->zoomMeeting; } /** * @param ZoomMeeting $zoomMeeting */ public function setZoomMeeting(ZoomMeeting $zoomMeeting) { $this->zoomMeeting = $zoomMeeting; } /** * @return string */ public function getLessonSpace() { return $this->lessonSpace; } /** * @param string $lessonSpace */ public function setLessonSpace($lessonSpace) { $this->lessonSpace = $lessonSpace; } /** * @return Collection */ public function getBookings() { return $this->bookings; } /** * @param Collection $bookings */ public function setBookings(Collection $bookings) { $this->bookings = $bookings; } /** * @return Token */ public function getGoogleCalendarEventId() { return $this->googleCalendarEventId; } /** * @param Token $googleCalendarEventId */ public function setGoogleCalendarEventId($googleCalendarEventId) { $this->googleCalendarEventId = $googleCalendarEventId; } /** * @return string */ public function getGoogleMeetUrl() { return $this->googleMeetUrl; } /** * @param string $googleMeetUrl */ public function setGoogleMeetUrl($googleMeetUrl) { $this->googleMeetUrl = $googleMeetUrl; } /** * @return Label */ public function getOutlookCalendarEventId() { return $this->outlookCalendarEventId; } /** * @param Label $outlookCalendarEventId */ public function setOutlookCalendarEventId($outlookCalendarEventId) { $this->outlookCalendarEventId = $outlookCalendarEventId; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'eventId' => $this->getEventId() ? $this->getEventId()->getValue() : null, 'periodStart' => $this->getPeriodStart()->getValue()->format('Y-m-d H:i:s'), 'periodEnd' => $this->getPeriodEnd()->getValue()->format('Y-m-d H:i:s'), 'zoomMeeting' => $this->getZoomMeeting() ? $this->getZoomMeeting()->toArray() : null, 'lessonSpace' => $this->getLessonSpace() ?: null, 'bookings' => $this->getBookings() ? $this->getBookings()->toArray() : [], 'googleCalendarEventId' => $this->getGoogleCalendarEventId() ? $this->getGoogleCalendarEventId()->getValue(): null, 'googleMeetUrl' => $this->getGoogleMeetUrl(), 'outlookCalendarEventId' => $this->getOutlookCalendarEventId() ? $this->getOutlookCalendarEventId()->getValue() : null ]; } } Entity/Booking/Event/CustomerBookingEventPeriod.php 0000666 00000003311 15165375612 0016476 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class CustomerBookingEventPeriod * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class CustomerBookingEventPeriod { /** @var Id */ private $id; /** @var Id */ private $customerBookingId; /** @var Id */ protected $eventPeriodId; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getEventPeriodId() { return $this->eventPeriodId; } /** * @param Id $eventPeriodId */ public function setEventPeriodId(Id $eventPeriodId) { $this->eventPeriodId = $eventPeriodId; } /** * @return Id */ public function getCustomerBookingId() { return $this->customerBookingId; } /** * @param Id $customerBookingId */ public function setCustomerBookingId(Id $customerBookingId) { $this->customerBookingId = $customerBookingId; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'eventPeriodId' => $this->getEventPeriodId() ? $this->getEventPeriodId()->getValue() : null, 'customerBookingId' => $this->getCustomerBookingId() ? $this->getCustomerBookingId()->getValue() : null ]; } } Entity/Booking/Event/EventTag.php 0000666 00000003005 15165375612 0012734 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class EventTag * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class EventTag { /** @var Id */ private $id; /** @var Id */ private $eventId; /** @var Name */ protected $name; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getEventId() { return $this->eventId; } /** * @param Id $eventId */ public function setEventId(Id $eventId) { $this->eventId = $eventId; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'eventId' => $this->getEventId() ? $this->getEventId()->getValue() : null, 'name' => $this->getName() ? $this->getName()->getValue() : null, ]; } } Entity/Booking/Event/CustomerBookingEventTicket.php 0000666 00000005151 15165375612 0016503 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; /** * Class CustomerBookingEventTicket * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class CustomerBookingEventTicket { /** @var Id */ private $id; /** @var Id */ private $customerBookingId; /** @var Id */ protected $eventTicketId; /** @var IntegerValue */ protected $persons; /** @var Price */ protected $price; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Id */ public function getCustomerBookingId() { return $this->customerBookingId; } /** * @param Id $customerBookingId */ public function setCustomerBookingId(Id $customerBookingId) { $this->customerBookingId = $customerBookingId; } /** * @return Id */ public function getEventTicketId() { return $this->eventTicketId; } /** * @param Id $eventTicketId */ public function setEventTicketId(Id $eventTicketId) { $this->eventTicketId = $eventTicketId; } /** * @return IntegerValue */ public function getPersons() { return $this->persons; } /** * @param IntegerValue $persons */ public function setPersons(IntegerValue $persons) { $this->persons = $persons; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'eventTicketId' => $this->getEventTicketId() ? $this->getEventTicketId()->getValue() : null, 'customerBookingId' => $this->getCustomerBookingId() ? $this->getCustomerBookingId()->getValue() : null, 'persons' => $this->getPersons() ? $this->getPersons()->getValue() : null, 'price' => $this->getPrice() ? $this->getPrice()->getValue() : null ]; } } Entity/Booking/Event/EventTicket.php 0000666 00000011063 15165375612 0013447 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; /** * Class EventTicket * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class EventTicket { /** @var Id */ private $id; /** @var Id */ private $eventId; /** @var Name */ protected $name; /** @var BooleanValueObject */ private $enabled; /** @var Price */ protected $price; /** @var Price */ protected $dateRangePrice; /** @var IntegerValue */ private $spots; /** @var Json */ protected $dateRanges; /** @var IntegerValue */ private $sold; /** @var Json */ protected $translations; /** * @return Json */ public function getDateRanges() { return $this->dateRanges; } /** * @param Json $dateRanges */ public function setDateRanges($dateRanges) { $this->dateRanges = $dateRanges; } /** * @return IntegerValue */ public function getSpots() { return $this->spots; } /** * @param IntegerValue $spots */ public function setSpots($spots) { $this->spots = $spots; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice($price) { $this->price = $price; } /** * @return Price */ public function getDateRangePrice() { return $this->dateRangePrice; } /** * @param Price $dateRangePrice */ public function setDateRangePrice($dateRangePrice) { $this->dateRangePrice = $dateRangePrice; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName($name) { $this->name = $name; } /** * @return BooleanValueObject */ public function getEnabled() { return $this->enabled; } /** * @param BooleanValueObject $enabled */ public function setEnabled($enabled) { $this->enabled = $enabled; } /** * @return Id */ public function getEventId() { return $this->eventId; } /** * @param Id $eventId */ public function setEventId($eventId) { $this->eventId = $eventId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return IntegerValue */ public function getSold() { return $this->sold; } /** * @param IntegerValue $sold */ public function setSold($sold) { $this->sold = $sold; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return [ 'id' => $this->getId() ? $this->getId()->getValue() : null, 'eventId' => $this->getEventId() ? $this->getEventId()->getValue() : null, 'name' => $this->getName() ? $this->getName()->getValue() : null, 'enabled' => $this->getEnabled() ? $this->getEnabled()->getValue() : null, 'price' => $this->getPrice() ? $this->getPrice()->getValue() : null, 'dateRangePrice' => $this->getDateRangePrice() ? $this->getDateRangePrice()->getValue() : null, 'spots' => $this->getSpots() ? $this->getSpots()->getValue() : null, 'dateRanges' => $this->getDateRanges() ? $this->getDateRanges()->getValue() : null, 'sold' => $this->getSold() ? $this->getSold()->getValue() : 0, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, ]; } } Entity/Booking/Event/Event.php 0000666 00000042041 15165375612 0012303 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Event; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\Recurring; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class Event * * @package AmeliaBooking\Domain\Entity\Booking\Event */ class Event extends AbstractBookable { /** @var Id */ protected $parentId; /** @var BookingStatus */ protected $status; /** @var Collection */ protected $bookings; /** @var DateTimeValue */ protected $bookingOpens; /** @var DateTimeValue */ protected $bookingCloses; /** @var string */ protected $bookingOpensRec; /** @var string */ protected $bookingClosesRec; /** @var string */ protected $ticketRangeRec; /** @var Recurring */ private $recurring; /** @var IntegerValue */ private $maxCapacity; /** @var BooleanValueObject */ private $show; /** @var Collection */ protected $periods; /** @var Collection */ private $tags; /** @var Collection */ private $gallery; /** @var Collection */ private $providers; /** @var bool */ protected $notifyParticipants; /** @var Id */ protected $locationId; /** @var Location */ private $location; /** @var Name */ protected $customLocation; /** @var DateTimeValue */ protected $created; /** @var Name */ private $zoomUserId; /** @var Id */ private $organizerId; /** @var BooleanValueObject */ private $bringingAnyone; /** @var BooleanValueObject */ private $bookMultipleTimes; /** @var Json */ protected $translations; /** @var Collection */ private $customTickets; /** @var BooleanValueObject */ private $customPricing; /** @var IntegerValue */ private $maxCustomCapacity; /** @var IntegerValue */ private $closeAfterMin; /** @var BooleanValueObject */ private $closeAfterMinBookings; /** @var BooleanValueObject */ private $aggregatedPrice; /** @var IntegerValue */ private $maxExtraPeople; /** @var DateTimeValue */ private $initialEventStart; /** @var DateTimeValue */ private $initialEventEnd; /** * @return Id */ public function getParentId() { return $this->parentId; } /** * @param Id $parentId */ public function setParentId(Id $parentId) { $this->parentId = $parentId; } /** * @return Recurring */ public function getRecurring() { return $this->recurring; } /** * @param Recurring $recurring */ public function setRecurring(Recurring $recurring) { $this->recurring = $recurring; } /** * @return IntegerValue */ public function getMaxCapacity() { return $this->maxCapacity; } /** * @param IntegerValue $maxCapacity */ public function setMaxCapacity(IntegerValue $maxCapacity) { $this->maxCapacity = $maxCapacity; } /** * @return BooleanValueObject */ public function getShow() { return $this->show; } /** * @param BooleanValueObject $show */ public function setShow(BooleanValueObject $show) { $this->show = $show; } /** * @return Collection */ public function getBookings() { return $this->bookings; } /** * @param Collection $bookings */ public function setBookings(Collection $bookings) { $this->bookings = $bookings; } /** * @return Collection */ public function getPeriods() { return $this->periods; } /** * @param Collection $periods */ public function setPeriods(Collection $periods) { $this->periods = $periods; } /** * @return DateTimeValue */ public function getBookingOpens() { return $this->bookingOpens; } /** * @param DateTimeValue|null $bookingOpens */ public function setBookingOpens(DateTimeValue $bookingOpens = null) { $this->bookingOpens = $bookingOpens; } /** * @return DateTimeValue */ public function getBookingCloses() { return $this->bookingCloses; } /** * @param DateTimeValue|null $bookingCloses */ public function setBookingCloses(DateTimeValue $bookingCloses = null) { $this->bookingCloses = $bookingCloses; } /** * @return string */ public function getBookingOpensRec() { return $this->bookingOpensRec; } /** * @param string $bookingOpensRec */ public function setBookingOpensRec($bookingOpensRec) { $this->bookingOpensRec = $bookingOpensRec; } /** * @return string */ public function getBookingClosesRec() { return $this->bookingClosesRec; } /** * @param string $bookingClosesRec */ public function setBookingClosesRec($bookingClosesRec) { $this->bookingClosesRec = $bookingClosesRec; } /** * @return string */ public function getTicketRangeRec() { return $this->ticketRangeRec; } /** * @param string $ticketRangeRec */ public function setTicketRangeRec($ticketRangeRec) { $this->ticketRangeRec = $ticketRangeRec; } /** * @return BookingStatus */ public function getStatus() { return $this->status; } /** * @param BookingStatus $status */ public function setStatus(BookingStatus $status) { $this->status = $status; } /** * @return Collection */ public function getCustomTickets() { return $this->customTickets; } /** * @param Collection $customTickets */ public function setCustomTickets(Collection $customTickets) { $this->customTickets = $customTickets; } /** * @return Collection */ public function getTags() { return $this->tags; } /** * @param Collection $tags */ public function setTags(Collection $tags) { $this->tags = $tags; } /** * @return Collection */ public function getGallery() { return $this->gallery; } /** * @param Collection $gallery */ public function setGallery(Collection $gallery) { $this->gallery = $gallery; } /** * @return Collection */ public function getProviders() { return $this->providers; } /** * @param Collection $providers */ public function setProviders(Collection $providers) { $this->providers = $providers; } /** * @return bool */ public function isNotifyParticipants() { return $this->notifyParticipants; } /** * @param bool $notifyParticipants */ public function setNotifyParticipants($notifyParticipants) { $this->notifyParticipants = $notifyParticipants; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return Location */ public function getLocation() { return $this->location; } /** * @param Location $location */ public function setLocation(Location $location) { $this->location = $location; } /** * @return Name */ public function getCustomLocation() { return $this->customLocation; } /** * @param Name $customLocation */ public function setCustomLocation(Name $customLocation) { $this->customLocation = $customLocation; } /** * @return DateTimeValue */ public function getCreated() { return $this->created; } /** * @param DateTimeValue $created */ public function setCreated(DateTimeValue $created) { $this->created = $created; } /** * @return Name */ public function getZoomUserId() { return $this->zoomUserId; } /** * @param Name $zoomUserId */ public function setZoomUserId(Name $zoomUserId) { $this->zoomUserId = $zoomUserId; } /** * @return Id */ public function getOrganizerId() { return $this->organizerId; } /** * @param Id $organizerId */ public function setOrganizerId($organizerId) { $this->organizerId = $organizerId; } /** * @return BookingType */ public function getType() { return new Bookingtype(Entities::EVENT); } /** * @return BooleanValueObject */ public function getBringingAnyone() { return $this->bringingAnyone; } /** * @param BooleanValueObject $bringingAnyone */ public function setBringingAnyone(BooleanValueObject $bringingAnyone) { $this->bringingAnyone = $bringingAnyone; } /** * @return BooleanValueObject */ public function getBookMultipleTimes() { return $this->bookMultipleTimes; } /** * @param BooleanValueObject $bookMultipleTimes */ public function setBookMultipleTimes(BooleanValueObject $bookMultipleTimes) { $this->bookMultipleTimes = $bookMultipleTimes; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return BooleanValueObject */ public function getCustomPricing() { return $this->customPricing; } /** * @param BooleanValueObject $customPricing */ public function setCustomPricing($customPricing) { $this->customPricing = $customPricing; } /** * @return IntegerValue */ public function getMaxCustomCapacity() { return $this->maxCustomCapacity; } /** * @param IntegerValue $maxCustomCapacity */ public function setMaxCustomCapacity($maxCustomCapacity) { $this->maxCustomCapacity = $maxCustomCapacity; } /** * @return IntegerValue */ public function getCloseAfterMin() { return $this->closeAfterMin; } /** * @param IntegerValue $closeAfterMin */ public function setCloseAfterMin($closeAfterMin) { $this->closeAfterMin = $closeAfterMin; } /** * @return BooleanValueObject */ public function getCloseAfterMinBookings() { return $this->closeAfterMinBookings; } /** * @param BooleanValueObject $closeAfterMinBookings */ public function setCloseAfterMinBookings($closeAfterMinBookings) { $this->closeAfterMinBookings = $closeAfterMinBookings; } /** * @return IntegerValue */ public function getMaxExtraPeople() { return $this->maxExtraPeople; } /** * @return DateTimeValue|null */ public function getInitialEventStart() { return $this->initialEventStart; } /** * @param DateTimeValue|null $initialEventStart */ public function setInitialEventStart(DateTimeValue $initialEventStart) { $this->initialEventStart = $initialEventStart; } /** * @return DateTimeValue|null */ public function getInitialEventEnd() { return $this->initialEventEnd; } /** * @param DateTimeValue|null $initialEventEnd */ public function setInitialEventEnd(DateTimeValue $initialEventEnd) { $this->initialEventEnd = $initialEventEnd; } /** * @param IntegerValue $maxExtraPeople */ public function setMaxExtraPeople($maxExtraPeople) { $this->maxExtraPeople = $maxExtraPeople; } /** * @return BooleanValueObject */ public function getAggregatedPrice() { return $this->aggregatedPrice; } /** * @param BooleanValueObject $aggregatedPrice */ public function setAggregatedPrice($aggregatedPrice) { $this->aggregatedPrice = $aggregatedPrice; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'bookings' => $this->getBookings() ? $this->getBookings()->toArray() : [], 'periods' => $this->getPeriods()->toArray(), 'bookingOpens' => $this->getBookingOpens() ? $this->getBookingOpens()->getValue()->format('Y-m-d H:i:s') : null, 'bookingCloses' => $this->getBookingCloses() ? $this->getBookingCloses()->getValue()->format('Y-m-d H:i:s') : null, 'bookingOpensRec' => $this->getBookingOpensRec(), 'bookingClosesRec' => $this->getBookingClosesRec(), 'ticketRangeRec' => $this->getTicketRangeRec(), 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, 'recurring' => $this->getRecurring() ? $this->getRecurring()->toArray() : null, 'maxCapacity' => $this->getMaxCapacity() ? $this->getMaxCapacity()->getValue() : null, 'maxCustomCapacity' => $this->getMaxCustomCapacity() ? $this->getMaxCustomCapacity()->getValue() : null, 'show' => $this->getShow() ? $this->getShow()->getValue() : null, 'tags' => $this->getTags() ? $this->getTags()->toArray() : null, 'customTickets' => $this->getCustomTickets() ? $this->getCustomTickets()->toArray() : [], 'gallery' => $this->getGallery() ? $this->getGallery()->toArray() : [], 'providers' => $this->getProviders() ? $this->getProviders()->toArray() : [], 'notifyParticipants' => $this->isNotifyParticipants(), 'locationId' => $this->getLocationId() ? $this->getLocationId()->getValue() : null, 'location' => $this->getLocation() ? $this->getLocation()->toArray() : null, 'customLocation' => $this->getCustomLocation() ? $this->getCustomLocation()->getValue() : null, 'parentId' => $this->getParentId() ? $this->getParentId()->getValue() : null, 'created' => $this->getCreated() ? $this->getCreated()->getValue()->format('Y-m-d H:i:s') : null, 'zoomUserId' => $this->getZoomUserId() ? $this->getZoomUserId()->getValue() : null, 'organizerId' => $this->getOrganizerId() ? $this->getOrganizerId()->getValue() : null, 'type' => $this->getType()->getValue(), 'bringingAnyone' => $this->getBringingAnyone() ? $this->getBringingAnyone()->getValue() : null, 'bookMultipleTimes' => $this->getBookMultipleTimes() ? $this->getBookMultipleTimes()->getValue() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, 'customPricing' => $this->getCustomPricing() ? $this->getCustomPricing()->getValue() : null, 'closeAfterMin' => $this->getCloseAfterMin() ? $this->getCloseAfterMin()->getValue() : null, 'closeAfterMinBookings' => $this->getCloseAfterMinBookings() ? $this->getCloseAfterMinBookings()->getValue() : null, 'maxExtraPeople' => $this->getMaxExtraPeople() ? $this->getMaxExtraPeople()->getValue() : null, 'initialEventStart' => $this->getInitialEventStart() ? $this->getInitialEventStart()->getValue()->format('Y-m-d H:i:s') : null, 'initialEventEnd' => $this->getInitialEventEnd() ? $this->getInitialEventEnd()->getValue()->format('Y-m-d H:i:s') : null, 'aggregatedPrice' => $this->getAggregatedPrice() ? $this->getAggregatedPrice()->getValue() : null, ] ); } } Entity/Booking/Appointment/CustomerBooking.php 0000666 00000020550 15165375612 0015552 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomerService; use AmeliaBooking\Domain\Entity\Booking\AbstractCustomerBooking; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class CustomerBooking * * @package AmeliaBooking\Domain\Entity\Booking\Appointment */ class CustomerBooking extends AbstractCustomerBooking { /** @var Id */ private $appointmentId; /** @var IntegerValue */ private $persons; /** @var Collection */ private $payments; /** @var Collection */ private $ticketsBooking; /** @var Token */ private $token; /** @var IntegerValue */ private $utcOffset; /** @var BooleanValueObject */ protected $aggregatedPrice; /** @var BooleanValueObject */ protected $isChangedStatus; /** @var PackageCustomerService */ protected $packageCustomerService; /** @var BooleanValueObject */ protected $deposit; /** @var BooleanValueObject */ protected $isLastBooking; /** @var PositiveDuration */ private $duration; /** @var DateTimeValue */ private $created; /** @var BooleanValueObject */ private $actionsCompleted; /** @var BooleanValueObject */ private $isUpdated; /** * CustomerBooking constructor. * * @param Id $customerId * @param BookingStatus $status * @param IntegerValue $persons */ public function __construct( Id $customerId, BookingStatus $status, IntegerValue $persons ) { parent::__construct($customerId, $status); $this->persons = $persons; } /** * @return Id */ public function getAppointmentId() { return $this->appointmentId; } /** * @param Id $appointmentId */ public function setAppointmentId(Id $appointmentId) { $this->appointmentId = $appointmentId; } /** * @return IntegerValue */ public function getPersons() { return $this->persons; } /** * @param IntegerValue $persons */ public function setPersons(IntegerValue $persons) { $this->persons = $persons; } /** * @return Collection */ public function getPayments() { return $this->payments; } /** * @param Collection $payments */ public function setPayments(Collection $payments) { $this->payments = $payments; } /** * @return Token */ public function getToken() { return $this->token; } /** * @param Token $token */ public function setToken(Token $token) { $this->token = $token; } /** * @return IntegerValue */ public function getUtcOffset() { return $this->utcOffset; } /** * @param IntegerValue $utcOffset */ public function setUtcOffset(IntegerValue $utcOffset) { $this->utcOffset = $utcOffset; } /** * @return BooleanValueObject */ public function getAggregatedPrice() { return $this->aggregatedPrice; } /** * @param BooleanValueObject $aggregatedPrice */ public function setAggregatedPrice(BooleanValueObject $aggregatedPrice) { $this->aggregatedPrice = $aggregatedPrice; } /** * @return BooleanValueObject */ public function isChangedStatus() { return $this->isChangedStatus; } /** * @param BooleanValueObject $isChangedStatus */ public function setChangedStatus(BooleanValueObject $isChangedStatus) { $this->isChangedStatus = $isChangedStatus; } /** * @return PackageCustomerService */ public function getPackageCustomerService() { return $this->packageCustomerService; } /** * @param PackageCustomerService $packageCustomerService */ public function setPackageCustomerService(PackageCustomerService $packageCustomerService) { $this->packageCustomerService = $packageCustomerService; } /** * @return BooleanValueObject */ public function getDeposit() { return $this->deposit; } /** * @param BooleanValueObject $deposit */ public function setDeposit(BooleanValueObject $deposit) { $this->deposit = $deposit; } /** * @return BooleanValueObject */ public function isLastBooking() { return $this->isLastBooking; } /** * @param BooleanValueObject $isLastBooking */ public function setLastBooking($isLastBooking) { $this->isLastBooking = $isLastBooking; } /** * @return Collection */ public function getTicketsBooking() { return $this->ticketsBooking; } /** * @param Collection $ticketsBooking */ public function setTicketsBooking(Collection $ticketsBooking) { $this->ticketsBooking = $ticketsBooking; } /** * @return PositiveDuration */ public function getDuration() { return $this->duration; } /** * @param PositiveDuration $duration */ public function setDuration(PositiveDuration $duration) { $this->duration = $duration; } /** * @return DateTimeValue */ public function getCreated() { return $this->created; } /** * @param DateTimeValue $created */ public function setCreated($created) { $this->created = $created; } /** * @return BooleanValueObject */ public function getActionsCompleted() { return $this->actionsCompleted; } /** * @param BooleanValueObject $actionsCompleted */ public function setActionsCompleted($actionsCompleted) { $this->actionsCompleted = $actionsCompleted; } /** * @return BooleanValueObject|null */ public function isUpdated() { return $this->isUpdated; } /** * @param BooleanValueObject $isUpdated */ public function setUpdated(BooleanValueObject $isUpdated) { $this->isUpdated = $isUpdated; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'appointmentId' => null !== $this->getAppointmentId() ? $this->getAppointmentId()->getValue() : null, 'persons' => $this->getPersons()->getValue(), 'token' => $this->getToken() ? $this->getToken()->getValue() : null, 'payments' => null !== $this->getPayments() ? $this->getPayments()->toArray() : null, 'utcOffset' => null !== $this->getUtcOffset() ? $this->getUtcOffset()->getValue() : null, 'aggregatedPrice' => $this->getAggregatedPrice() ? $this->getAggregatedPrice()->getValue() : null, 'isChangedStatus' => $this->isChangedStatus() ? $this->isChangedStatus()->getValue() : null, 'isLastBooking' => $this->isLastBooking() ? $this->isLastBooking()->getValue() : null, 'packageCustomerService' => $this->getPackageCustomerService() ? $this->getPackageCustomerService()->toArray() : null, 'ticketsData' => null !== $this->getTicketsBooking() ? $this->getTicketsBooking()->toArray() : null, 'duration' => $this->getDuration() ? $this->getDuration()->getValue() : null, 'created' => $this->getCreated() ? $this->getCreated()->getValue()->format('Y-m-d H:i:s') : null, 'actionsCompleted' => $this->getActionsCompleted() ? $this->getActionsCompleted()->getValue() : null, 'isUpdated' => $this->isUpdated() ? $this->isUpdated()->getValue() : null, ] ); } } Entity/Booking/Appointment/Appointment.php 0000666 00000023110 15165375612 0014731 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Booking\AbstractBooking; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Entity\Zoom\ZoomMeeting; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class Appointment * * @package AmeliaBooking\Domain\Entity\Booking\Appointment */ class Appointment extends AbstractBooking { /** @var Id */ private $parentId; /** @var Id */ private $serviceId; /** @var Service */ private $service; /** @var Id */ private $providerId; /** @var Provider */ private $provider; /** @var Id */ private $locationId; /** @var Location */ private $location; /** @var Token */ private $googleCalendarEventId; /** @var string */ private $googleMeetUrl; /** @var Label */ private $outlookCalendarEventId; /** @var DateTimeValue */ protected $bookingStart; /** @var DateTimeValue */ protected $bookingEnd; /** @var ZoomMeeting */ private $zoomMeeting; /** @var string */ private $lessonSpace; /** @var Collection */ private $resources; /** @var BooleanValueObject */ protected $isRescheduled; /** @var BooleanValueObject */ protected $isFull; /** * Appointment constructor. * * @param DateTimeValue $bookingStart * @param DateTimeValue $bookingEnd * @param bool $notifyParticipants * @param Id $serviceId * @param Id $providerId */ public function __construct( DateTimeValue $bookingStart, DateTimeValue $bookingEnd, $notifyParticipants, Id $serviceId, Id $providerId ) { parent::__construct($notifyParticipants); $this->bookingStart = $bookingStart; $this->bookingEnd = $bookingEnd; $this->serviceId = $serviceId; $this->providerId = $providerId; $this->resources = new Collection(); } /** * @return Id */ public function getServiceId() { return $this->serviceId; } /** * @param Id $serviceId */ public function setServiceId(Id $serviceId) { $this->serviceId = $serviceId; } /** * @return Service */ public function getService() { return $this->service; } /** * @param Service $service */ public function setService(Service $service) { $this->service = $service; } /** * @return Id */ public function getProviderId() { return $this->providerId; } /** * @param Id $providerId */ public function setProviderId(Id $providerId) { $this->providerId = $providerId; } /** * @return Provider */ public function getProvider() { return $this->provider; } /** * @param Provider $provider */ public function setProvider(Provider $provider) { $this->provider = $provider; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return Location */ public function getLocation() { return $this->location; } /** * @param Location $location */ public function setLocation(Location $location) { $this->location = $location; } /** * @return Token */ public function getGoogleCalendarEventId() { return $this->googleCalendarEventId; } /** * @param Token $googleCalendarEventId */ public function setGoogleCalendarEventId($googleCalendarEventId) { $this->googleCalendarEventId = $googleCalendarEventId; } /** * @return string */ public function getGoogleMeetUrl() { return $this->googleMeetUrl; } /** * @param string $googleMeetUrl */ public function setGoogleMeetUrl($googleMeetUrl) { $this->googleMeetUrl = $googleMeetUrl; } /** * @return Label */ public function getOutlookCalendarEventId() { return $this->outlookCalendarEventId; } /** * @param Label $outlookCalendarEventId */ public function setOutlookCalendarEventId($outlookCalendarEventId) { $this->outlookCalendarEventId = $outlookCalendarEventId; } /** * @return DateTimeValue */ public function getBookingStart() { return $this->bookingStart; } /** * @param DateTimeValue $bookingStart */ public function setBookingStart(DateTimeValue $bookingStart) { $this->bookingStart = $bookingStart; } /** * @return DateTimeValue */ public function getBookingEnd() { return $this->bookingEnd; } /** * @param DateTimeValue $bookingEnd */ public function setBookingEnd(DateTimeValue $bookingEnd) { $this->bookingEnd = $bookingEnd; } /** * @return BookingType */ public function getType() { return new Bookingtype(Entities::APPOINTMENT); } /** * @return ZoomMeeting */ public function getZoomMeeting() { return $this->zoomMeeting; } /** * @param ZoomMeeting $zoomMeeting */ public function setZoomMeeting(ZoomMeeting $zoomMeeting) { $this->zoomMeeting = $zoomMeeting; } /** * @return string */ public function getLessonSpace() { return $this->lessonSpace; } /** * @param string $lessonSpace */ public function setLessonSpace($lessonSpace) { $this->lessonSpace = $lessonSpace; } /** * @return Id */ public function getParentId() { return $this->parentId; } /** * @param Id $parentId */ public function setParentId(Id $parentId) { $this->parentId = $parentId; } /** * @return BooleanValueObject */ public function isRescheduled() { return $this->isRescheduled; } /** * @param BooleanValueObject $isRescheduled */ public function setRescheduled(BooleanValueObject $isRescheduled) { $this->isRescheduled = $isRescheduled; } /** * @return BooleanValueObject */ public function isFull() { return $this->isFull; } /** * @param BooleanValueObject $isFull */ public function setFull(BooleanValueObject $isFull) { $this->isFull = $isFull; } /** * @return Collection */ public function getResources() { return $this->resources; } /** * @param Collection $resources */ public function setResources(Collection $resources) { $this->resources = $resources; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'serviceId' => $this->getServiceId()->getValue(), 'parentId' => $this->getParentId() ? $this->getParentId()->getValue() : null, 'providerId' => $this->getProviderId()->getValue(), 'locationId' => null !== $this->getLocationId() ? $this->getLocationId()->getValue() : null, 'provider' => null !== $this->getProvider() ? $this->getProvider()->toArray() : null, 'service' => null !== $this->getService() ? $this->getService()->toArray() : null, 'location' => null !== $this->getLocation() ? $this->getLocation()->toArray() : null, 'googleCalendarEventId' => null !== $this->getGoogleCalendarEventId() ? $this->getGoogleCalendarEventId()->getValue() : null, 'googleMeetUrl' => null !== $this->getGoogleMeetUrl() ? $this->getGoogleMeetUrl() : null, 'outlookCalendarEventId' => null !== $this->getOutlookCalendarEventId() ? $this->getOutlookCalendarEventId()->getValue() : null, 'zoomMeeting' => $this->getZoomMeeting() ? $this->getZoomMeeting()->toArray() : null, 'lessonSpace' => $this->getLessonSpace() ?: null, 'bookingStart' => $this->getBookingStart()->getValue()->format('Y-m-d H:i:s'), 'bookingEnd' => $this->getBookingEnd()->getValue()->format('Y-m-d H:i:s'), 'type' => $this->getType()->getValue(), 'isRescheduled' => $this->isRescheduled() ? $this->isRescheduled()->getValue() : null, 'isFull' => $this->isFull() ? $this->isFull()->getValue() : null, 'resources' => $this->getResources()->toArray(), ] ); } } Entity/Booking/Appointment/CustomerBookingExtra.php 0000666 00000006700 15165375612 0016557 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking\Appointment; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; /** * Class CustomerBookingExtra * * @package AmeliaBooking\Domain\Entity\Booking\Appointment */ class CustomerBookingExtra { /** @var Id */ private $id; /** @var Id */ private $customerBookingId; /** @var Id */ private $extraId; /** @var PositiveInteger */ private $quantity; /** @var Price */ protected $price; /** @var BooleanValueObject */ protected $aggregatedPrice; /** * CustomerBookingExtra constructor. * * @param Id $extraId * @param PositiveInteger $quantity */ public function __construct( Id $extraId, PositiveInteger $quantity ) { $this->extraId = $extraId; $this->quantity = $quantity; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getCustomerBookingId() { return $this->customerBookingId; } /** * @param Id $customerBookingId */ public function setCustomerBookingId(Id $customerBookingId) { $this->customerBookingId = $customerBookingId; } /** * @return Id */ public function getExtraId() { return $this->extraId; } /** * @param Id $extraId */ public function setExtraId(Id $extraId) { $this->extraId = $extraId; } /** * @return PositiveInteger */ public function getQuantity() { return $this->quantity; } /** * @param PositiveInteger $quantity */ public function setQuantity(PositiveInteger $quantity) { $this->quantity = $quantity; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return BooleanValueObject */ public function getAggregatedPrice() { return $this->aggregatedPrice; } /** * @param BooleanValueObject $aggregatedPrice */ public function setAggregatedPrice(BooleanValueObject $aggregatedPrice) { $this->aggregatedPrice = $aggregatedPrice; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'customerBookingId' => $this->getCustomerBookingId() ? $this->getCustomerBookingId()->getValue() : null, 'extraId' => $this->getExtraId()->getValue(), 'quantity' => $this->getQuantity() ? $this->getQuantity()->getValue() : 1, 'price' => null !== $this->getPrice() ? $this->getPrice()->getValue() : null, 'aggregatedPrice' => $this->getAggregatedPrice() ? $this->getAggregatedPrice()->getValue() : null, ]; } } Entity/Booking/Reservation.php 0000666 00000017067 15165375612 0012454 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; use AmeliaBooking\Domain\Entity\Bookable\Service\Package; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Entity\Booking\Event\Event; use AmeliaBooking\Domain\Entity\Payment\Payment; use AmeliaBooking\Domain\Entity\User\AbstractUser; use AmeliaBooking\Domain\Entity\User\Customer; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class Reservation * * @package AmeliaBooking\Domain\Entity\Booking */ class Reservation { /** @var Appointment|Event */ private $reservation; /** @var CustomerBooking */ private $booking; /** @var AbstractBookable */ private $bookable; /** @var Customer */ private $customer; /** @var Label */ private $locale; /** @var Label */ private $timeZone; /** @var BooleanValueObject */ private $isNewUser; /** @var BooleanValueObject */ private $isStatusChanged; /** @var BooleanValueObject */ private $applyDeposit; /** @var array */ private $uploadedCustomFieldFilesInfo; /** @var Collection */ private $recurring; /** @var Collection */ private $packageReservations; /** @var Collection */ private $packageCustomerServices; /** @var BooleanValueObject */ private $couponValidation; /** @var BooleanValueObject */ private $customFieldsValidation; /** @var BooleanValueObject */ private $availabilityValidation; /** @var AbstractUser $user */ private $loggedInUser; /** @var Payment $payment */ private $payment; /** * @return BooleanValueObject */ public function hasCouponValidation() { return $this->couponValidation; } /** * @param BooleanValueObject $couponValidation */ public function setCouponValidation(BooleanValueObject $couponValidation) { $this->couponValidation = $couponValidation; } /** * @return BooleanValueObject */ public function hasCustomFieldsValidation() { return $this->customFieldsValidation; } /** * @param BooleanValueObject $customFieldsValidation */ public function setCustomFieldsValidation(BooleanValueObject $customFieldsValidation) { $this->customFieldsValidation = $customFieldsValidation; } /** * @return BooleanValueObject */ public function hasAvailabilityValidation() { return $this->availabilityValidation; } /** * @param BooleanValueObject $availabilityValidation */ public function setAvailabilityValidation(BooleanValueObject $availabilityValidation) { $this->availabilityValidation = $availabilityValidation; } /** * @return Appointment|Event */ public function getReservation() { return $this->reservation; } /** * @param Appointment|Event|Package $reservation */ public function setReservation($reservation) { $this->reservation = $reservation; } /** * @return CustomerBooking */ public function getBooking() { return $this->booking; } /** * @param CustomerBooking $booking */ public function setBooking(CustomerBooking $booking) { $this->booking = $booking; } /** * @return AbstractBookable */ public function getBookable() { return $this->bookable; } /** * @param AbstractBookable $bookable */ public function setBookable(AbstractBookable $bookable) { $this->bookable = $bookable; } /** * @return Customer */ public function getCustomer() { return $this->customer; } /** * @param Customer $customer */ public function setCustomer(Customer $customer) { $this->customer = $customer; } /** * @return Label */ public function getLocale() { return $this->locale; } /** * @param Label $locale */ public function setLocale(Label $locale) { $this->locale = $locale; } /** * @return Label */ public function getTimeZone() { return $this->timeZone; } /** * @param Label $timeZone */ public function setTimeZone(Label $timeZone) { $this->timeZone = $timeZone; } /** * @return Collection */ public function getRecurring() { return $this->recurring; } /** * @param Collection $recurring */ public function setRecurring(Collection $recurring) { $this->recurring = $recurring; } /** * @return Collection */ public function getPackageReservations() { return $this->packageReservations; } /** * @param Collection $packageReservations */ public function setPackageReservations(Collection $packageReservations) { $this->packageReservations = $packageReservations; } /** * @return Collection */ public function getPackageCustomerServices() { return $this->packageCustomerServices; } /** * @param Collection $packageCustomerServices */ public function setPackageCustomerServices(Collection $packageCustomerServices) { $this->packageCustomerServices = $packageCustomerServices; } /** * @return BooleanValueObject */ public function isNewUser() { return $this->isNewUser; } /** * @param BooleanValueObject $isNewUser */ public function setIsNewUser(BooleanValueObject $isNewUser) { $this->isNewUser = $isNewUser; } /** * @return BooleanValueObject */ public function isStatusChanged() { return $this->isStatusChanged; } /** * @param BooleanValueObject $isStatusChanged */ public function setIsStatusChanged(BooleanValueObject $isStatusChanged) { $this->isStatusChanged = $isStatusChanged; } /** * @return array */ public function getUploadedCustomFieldFilesInfo() { return $this->uploadedCustomFieldFilesInfo; } /** * @param array $uploadedCustomFieldFilesInfo */ public function setUploadedCustomFieldFilesInfo(array $uploadedCustomFieldFilesInfo) { $this->uploadedCustomFieldFilesInfo = $uploadedCustomFieldFilesInfo; } /** * @return BooleanValueObject */ public function getApplyDeposit() { return $this->applyDeposit; } /** * @param BooleanValueObject $applyDeposit */ public function setApplyDeposit(BooleanValueObject $applyDeposit) { $this->applyDeposit = $applyDeposit; } /** * @return AbstractUser */ public function getLoggedInUser() { return $this->loggedInUser; } /** * @param AbstractUser $loggedInUser */ public function setLoggedInUser(AbstractUser $loggedInUser) { $this->loggedInUser = $loggedInUser; } /** * @return Payment */ public function getPayment() { return $this->payment; } /** * @param Payment $payment */ public function setPayment($payment) { $this->payment = $payment; } } Entity/Booking/SlotsEntities.php 0000666 00000003162 15165375612 0012753 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking; use AmeliaBooking\Domain\Collection\Collection; /** * Class SlotsEntities * * @package AmeliaBooking\Domain\Entity\Booking */ class SlotsEntities { /** @var Collection */ private $services; /** @var Collection */ private $providers; /** @var Collection */ private $locations; /** @var Collection */ private $resources; /** * @return Collection */ public function getServices() { return $this->services; } /** * @param Collection $services */ public function setServices(Collection $services) { $this->services = $services; } /** * @return Collection */ public function getProviders() { return $this->providers; } /** * @param Collection $providers */ public function setProviders(Collection $providers) { $this->providers = $providers; } /** * @return Collection */ public function getLocations() { return $this->locations; } /** * @param Collection $locations */ public function setLocations(Collection $locations) { $this->locations = $locations; } /** * @return Collection */ public function getResources() { return $this->resources; } /** * @param Collection $resources */ public function setResources(Collection $resources) { $this->resources = $resources; } } Entity/Booking/AbstractBooking.php 0000666 00000005645 15165375612 0013226 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Description; /** * Class AbstractBooking * * @package AmeliaBooking\Domain\Entity\Booking */ abstract class AbstractBooking { /** @var Id */ private $id; /** @var Collection */ protected $bookings; /** @var bool */ protected $notifyParticipants; /** @var Description */ protected $internalNotes; /** @var BookingStatus */ protected $status; /** * AbstractBooking constructor. * * @param boolean $notifyParticipants */ public function __construct($notifyParticipants) { $this->notifyParticipants = $notifyParticipants; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Collection */ public function getBookings() { return $this->bookings; } /** * @param Collection $bookings */ public function setBookings(Collection $bookings) { $this->bookings = $bookings; } /** * @return bool */ public function isNotifyParticipants() { return $this->notifyParticipants; } /** * @param bool $notifyParticipants */ public function setNotifyParticipants($notifyParticipants) { $this->notifyParticipants = $notifyParticipants; } /** * @return Description */ public function getInternalNotes() { return $this->internalNotes; } /** * @param Description $internalNotes */ public function setInternalNotes(Description $internalNotes) { $this->internalNotes = $internalNotes; } /** * @return BookingStatus */ public function getStatus() { return $this->status; } /** * @param BookingStatus $status */ public function setStatus(BookingStatus $status) { $this->status = $status; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'bookings' => null !== $this->getBookings() ? $this->getBookings()->toArray() : null, 'notifyParticipants' => $this->isNotifyParticipants(), 'internalNotes' => null !== $this->getInternalNotes() ? $this->getInternalNotes()->getValue() : null, 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, ]; } } Entity/Booking/AbstractCustomerBooking.php 0000666 00000011626 15165375612 0014744 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Booking; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Coupon\Coupon; use AmeliaBooking\Domain\Entity\User\Customer; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class AbstractCustomerBooking * * @package AmeliaBooking\Domain\Entity\Booking */ abstract class AbstractCustomerBooking { /** @var Id */ private $id; /** @var Id */ protected $customerId; /** @var Customer */ protected $customer; /** @var BookingStatus */ protected $status; /** @var Collection */ protected $extras; /** @var Id */ protected $couponId; /** @var Price */ protected $price; /** @var Coupon */ protected $coupon; /** @var Json */ protected $customFields; /** @var Json */ protected $info; /** * AbstractCustomerBooking constructor. * * @param Id $customerId * @param BookingStatus $status */ public function __construct( Id $customerId, BookingStatus $status ) { $this->customerId = $customerId; $this->status = $status; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getCustomerId() { return $this->customerId; } /** * @param Id $customerId */ public function setCustomerId(Id $customerId) { $this->customerId = $customerId; } /** * @return Customer */ public function getCustomer() { return $this->customer; } /** * @param Customer $customer */ public function setCustomer(Customer $customer) { $this->customer = $customer; } /** * @return BookingStatus */ public function getStatus() { return $this->status; } /** * @param BookingStatus $status */ public function setStatus(BookingStatus $status) { $this->status = $status; } /** * @return Collection */ public function getExtras() { return $this->extras; } /** * @param Collection $extras */ public function setExtras(Collection $extras) { $this->extras = $extras; } /** * @return Id */ public function getCouponId() { return $this->couponId; } /** * @param Id $couponId */ public function setCouponId(Id $couponId) { $this->couponId = $couponId; } /** * @return Coupon */ public function getCoupon() { return $this->coupon; } /** * @param Coupon $coupon */ public function setCoupon(Coupon $coupon) { $this->coupon = $coupon; } /** * @return Price */ public function getPrice() { return $this->price; } /** * @param Price $price */ public function setPrice(Price $price) { $this->price = $price; } /** * @return Json */ public function getCustomFields() { return $this->customFields; } /** * @param Json $customFields */ public function setCustomFields($customFields) { $this->customFields = $customFields; } /** * @return Json */ public function getInfo() { return $this->info; } /** * @param Json $info */ public function setInfo(Json $info) { $this->info = $info; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'customerId' => $this->getCustomerId()->getValue(), 'customer' => null !== $this->getCustomer() ? $this->getCustomer()->toArray() : null, 'status' => $this->getStatus()->getValue(), 'extras' => null !== $this->getExtras() ? $this->getExtras()->toArray() : null, 'couponId' => null !== $this->getCouponId() ? $this->getCouponId()->getValue() : null, 'price' => null !== $this->getPrice() ? $this->getPrice()->getValue() : null, 'coupon' => null !== $this->getCoupon() ? $this->getCoupon()->toArray() : null, 'customFields' => null !== $this->getCustomFields() ? $this->getCustomFields()->getValue() : null, 'info' => null !== $this->getInfo() ? $this->getInfo()->getValue() : null, ]; } } Entity/Payment/Payment.php 0000666 00000021627 15165375612 0011612 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Payment; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\PaymentStatus; use AmeliaBooking\Domain\ValueObjects\String\PaymentData; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class Payment * * @package AmeliaBooking\Domain\Entity\Payment */ class Payment { /** @var Id */ private $id; /** @var Id */ private $customerBookingId; /** @var Id */ private $packageCustomerId; /** @var Id */ private $parentId; /** @var Price */ private $amount; /** @var DateTimeValue */ private $dateTime; /** @var PaymentStatus */ private $status; /** @var PaymentGateway */ private $gateway; /** @var Name */ private $gatewayTitle; /** @var PaymentData */ private $data; /** @var DateTimeValue */ private $created; /** @var Name */ private $entity; /** @var BooleanValueObject */ private $actionsCompleted; /** @var Id */ private $wcOrderId; /** @var Url */ private $wcOrderUrl; /** @var Price */ private $wcItemCouponValue; /** @var Price */ private $wcItemTaxValue; /** @var string */ private $transactionId; /** * Payment constructor. * * @param Id $customerBookingId * @param Price $amount * @param DateTimeValue $dateTime * @param PaymentStatus $status * @param PaymentGateway $gateway * @param PaymentData $data */ public function __construct( Id $customerBookingId, Price $amount, DateTimeValue $dateTime, PaymentStatus $status, PaymentGateway $gateway, PaymentData $data ) { $this->customerBookingId = $customerBookingId; $this->amount = $amount; $this->dateTime = $dateTime; $this->status = $status; $this->gateway = $gateway; $this->data = $data; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Id */ public function getCustomerBookingId() { return $this->customerBookingId; } /** * @param Id $customerBookingId */ public function setCustomerBookingId($customerBookingId) { $this->customerBookingId = $customerBookingId; } /** * @return Id */ public function getPackageCustomerId() { return $this->packageCustomerId; } /** * @param Id $packageCustomerId */ public function setPackageCustomerId($packageCustomerId) { $this->packageCustomerId = $packageCustomerId; } /** * @return Id */ public function getParentId() { return $this->parentId; } /** * @param Id $parentId */ public function setParentId($parentId) { $this->parentId = $parentId; } /** * @return Price */ public function getAmount() { return $this->amount; } /** * @param Price $amount */ public function setAmount($amount) { $this->amount = $amount; } /** * @return DateTimeValue */ public function getDateTime() { return $this->dateTime; } /** * @param DateTimeValue $dateTime */ public function setDateTime($dateTime) { $this->dateTime = $dateTime; } /** * @return PaymentStatus */ public function getStatus() { return $this->status; } /** * @param PaymentStatus $status */ public function setStatus($status) { $this->status = $status; } /** * @return PaymentGateway */ public function getGateway() { return $this->gateway; } /** * @param PaymentGateway $gateway */ public function setGateway($gateway) { $this->gateway = $gateway; } /** * @return Name */ public function getGatewayTitle() { return $this->gatewayTitle; } /** * @param Name $gatewayTitle */ public function setGatewayTitle($gatewayTitle) { $this->gatewayTitle = $gatewayTitle; } /** * @return PaymentData */ public function getData() { return $this->data; } /** * @param PaymentData $data */ public function setData($data) { $this->data = $data; } /** * @return DateTimeValue */ public function getCreated() { return $this->created; } /** * @param DateTimeValue $created */ public function setCreated($created) { $this->created = $created; } /** * @return Name */ public function getEntity() { return $this->entity; } /** * @param Name $entity */ public function setEntity($entity) { $this->entity = $entity; } /** * @return BooleanValueObject */ public function getActionsCompleted() { return $this->actionsCompleted; } /** * @param BooleanValueObject $actionsCompleted */ public function setActionsCompleted($actionsCompleted) { $this->actionsCompleted = $actionsCompleted; } /** * @return Id */ public function getWcOrderId() { return $this->wcOrderId; } /** * @param Id $wcOrderId */ public function setWcOrderId($wcOrderId) { $this->wcOrderId = $wcOrderId; } /** * @return Url */ public function getWcOrderUrl() { return $this->wcOrderUrl; } /** * @param Url $wcOrderUrl */ public function setWcOrderUrl($wcOrderUrl) { $this->wcOrderUrl = $wcOrderUrl; } /** * @return Price */ public function getWcItemCouponValue() { return $this->wcItemCouponValue; } /** * @param Price $wcItemCouponValue */ public function setWcItemCouponValue($wcItemCouponValue) { $this->wcItemCouponValue = $wcItemCouponValue; } /** * @return Price */ public function getWcItemTaxValue() { return $this->wcItemTaxValue; } /** * @param Price $wcItemTaxValue */ public function setWcItemTaxValue($wcItemTaxValue) { $this->wcItemTaxValue = $wcItemTaxValue; } /** * @return string|null */ public function getTransactionId() { return $this->transactionId; } /** * @param string|null $transactionId */ public function setTransactionId(string $transactionId) { $this->transactionId = $transactionId; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'customerBookingId' => $this->customerBookingId ? $this->customerBookingId->getValue() : null, 'packageCustomerId' => $this->packageCustomerId ? $this->packageCustomerId->getValue() : null, 'parentId' => $this->getParentId() ? $this->getParentId()->getValue() : null, 'amount' => $this->amount->getValue(), 'gateway' => $this->gateway->getName()->getValue(), 'gatewayTitle' => null !== $this->getGatewayTitle() ? $this->getGatewayTitle()->getValue() : '', 'dateTime' => null !== $this->dateTime ? $this->dateTime->getValue()->format('Y-m-d H:i:s') : null, 'status' => $this->status->getValue(), 'data' => $this->data->getValue(), 'entity' => $this->getEntity() ? $this->getEntity()->getValue() : null, 'created' => $this->getCreated() ? $this->getCreated()->getValue()->format('Y-m-d H:i:s') : null, 'actionsCompleted' => $this->getActionsCompleted() ? $this->getActionsCompleted()->getValue() : null, 'wcOrderId' => $this->getWcOrderId() ? $this->getWcOrderId()->getValue() : null, 'wcOrderUrl' => $this->getWcOrderUrl() ? $this->getWcOrderUrl()->getValue() : null, 'wcItemCouponValue' => $this->getWcItemCouponValue() ? $this->getWcItemCouponValue()->getValue() : null, 'wcItemTaxValue' => $this->getWcItemTaxValue() ? $this->getWcItemTaxValue()->getValue() : null, 'transactionId' => $this->getTransactionId(), ]; } } Entity/Payment/PaymentGateway.php 0000666 00000002301 15165375612 0013120 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Entity\Payment; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class PaymentGateway * * @package AmeliaBooking\Domain\Entity\Gateway */ class PaymentGateway { /** @var Id */ private $id; /** @var Name */ private $name; /** * PaymentGateway constructor. * * @param Name $name */ public function __construct(Name $name) { $this->setName($name); } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId($id) { $this->id = $id; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return array */ public function toArray() { return [ $this->getName()->getValue(), ]; } } Entity/Location/Location.php 0000666 00000011356 15165375612 0012076 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Location; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Address; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\GeoTag; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class Location * * @package AmeliaBooking\Domain\Entity\Location */ class Location { /** @var Id */ private $id; /** @var Status */ private $status; /** @var Name */ private $name; /** @var Description */ private $description; /** @var Address */ private $address; /** @var Phone */ private $phone; /** @var GeoTag */ private $coordinates; /** @var Picture */ private $picture; /** @var Url */ private $pin; /** @var Json */ protected $translations; /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return Name */ public function getName() { return $this->name; } /** * @param Name $name */ public function setName(Name $name) { $this->name = $name; } /** * @return Description */ public function getDescription() { return $this->description; } /** * @param Description $description */ public function setDescription(Description $description) { $this->description = $description; } /** * @return Address */ public function getAddress() { return $this->address; } /** * @param Address $address */ public function setAddress(Address $address) { $this->address = $address; } /** * @return Phone */ public function getPhone() { return $this->phone; } /** * @param Phone $phone */ public function setPhone(Phone $phone) { $this->phone = $phone; } /** * @return GeoTag */ public function getCoordinates() { return $this->coordinates; } /** * @param GeoTag $coordinates */ public function setCoordinates(GeoTag $coordinates) { $this->coordinates = $coordinates; } /** * @return Picture */ public function getPicture() { return $this->picture; } /** * @param Picture $picture */ public function setPicture(Picture $picture) { $this->picture = $picture; } /** * @return Url */ public function getPin() { return $this->pin; } /** * @param Url $pin */ public function setPin(Url $pin) { $this->pin = $pin; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'status' => null !== $this->getStatus() ? $this->getStatus()->getValue() : null, 'name' => $this->getName()->getValue(), 'description' => null !== $this->getDescription() ? $this->getDescription()->getValue() : null, 'address' => $this->getAddress()->getValue(), 'phone' => $this->getPhone()->getValue(), 'latitude' => $this->getCoordinates()->getLatitude(), 'longitude' => $this->getCoordinates()->getLongitude(), 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, 'pin' => null !== $this->getPin() ? $this->getPin()->getValue() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, ]; } } Entity/Location/ProviderLocation.php 0000666 00000003077 15165375612 0013612 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\Location; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class ProviderLocation * * @package AmeliaBooking\Domain\Entity\Location */ class ProviderLocation { /** @var Id */ private $id; /** @var Id */ private $locationId; /** @var Id */ private $userId; /** * @param Id $userId * @param Id $locationId */ public function __construct( Id $userId, Id $locationId ) { $this->userId = $userId; $this->locationId = $locationId; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return Id */ public function getUserId() { return $this->userId; } /** * @param Id $userId */ public function setUserId(Id $userId) { $this->userId = $userId; } /** * @return array */ public function toArray() { return [ 'id' => $this->id !== null ? $this->id->getValue() : null, 'locationId' => $this->locationId->getValue(), 'userId' => $this->userId->getValue(), ]; } } Entity/Entities.php 0000666 00000002667 15165375612 0010347 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity; /** * Class Entities * * @package AmeliaBooking\Domain\Entity */ class Entities { const APPOINTMENT = 'appointment'; const APPOINTMENTS = 'appointments'; const BOOKABLE = 'bookable'; const BOOKING = 'booking'; const BOOKINGS = 'bookings'; const CALENDAR = 'calendar'; const CATEGORIES = 'categories'; const CATEGORY = 'category'; const COUPON = 'coupon'; const COUPONS = 'coupons'; const CUSTOM_FIELD = 'custom_field'; const CUSTOM_FIELDS = 'custom_fields'; const CUSTOMER = 'customer'; const CUSTOMERS = 'customers'; const DASHBOARD = 'dashboard'; const EVENT = 'event'; const EVENTS = 'events'; const EMPLOYEE = 'employee'; const EMPLOYEES = 'employees'; const PROVIDER = 'provider'; const PROVIDERS = 'providers'; const TAGS = 'tags'; const EXTRA = 'extra'; const EXTRAS = 'extras'; const FINANCE = 'finance'; const LOCATION = 'location'; const LOCATIONS = 'locations'; const NOTIFICATION = 'notification'; const NOTIFICATIONS = 'notifications'; const PACKAGE = 'package'; const PACKAGES = 'packages'; const PAYMENT = 'payment'; const PAYMENTS = 'payments'; const RESOURCE = 'resource'; const RESOURCES = 'resources'; const SERVICE = 'service'; const SERVICES = 'services'; const SETTINGS = 'settings'; const USER = 'user'; const USERS = 'users'; } Entity/User/Customer.php 0000666 00000003066 15165375612 0011274 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\User; use AmeliaBooking\Domain\ValueObjects\Gender; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; /** * Class Customer * * @package AmeliaBooking\Domain\Entity\User */ class Customer extends AbstractUser { /** @var Gender */ private $gender; /** * @param Name $firstName * @param Name $lastName * @param Email $email * @param Phone $phone * @param Gender $gender */ public function __construct( Name $firstName, Name $lastName, Email $email, Phone $phone, Gender $gender ) { parent::__construct($firstName, $lastName, $email); $this->phone = $phone; $this->gender = $gender; } /** * @return Gender */ public function getGender() { return $this->gender; } /** * @param Gender $gender */ public function setGender(Gender $gender) { $this->gender = $gender; } /** * Get the user type in a string form */ public function getType() { return self::USER_ROLE_CUSTOMER; } /** * @return array */ public function toArray() { return array_merge( parent::toArray(), [ 'phone' => $this->getPhone()->getValue(), 'gender' => $this->getGender()->getValue(), ] ); } } Entity/User/Admin.php 0000666 00000000453 15165375612 0010520 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\User; /** * Class Admin * * @package AmeliaBooking\Domain\Entity\User */ class Admin extends AbstractUser { /** * Get the user type in a string form */ public function getType() { return self::USER_ROLE_ADMIN; } } Entity/User/AbstractUser.php 0000666 00000017631 15165375612 0012100 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\User; use AmeliaBooking\Domain\ValueObjects\DateTime\Birthday; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Password; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class AbstractUser * * @package AmeliaBooking\Domain\Entity\User * */ abstract class AbstractUser { const USER_ROLE_ADMIN = 'admin'; const USER_ROLE_PROVIDER = 'provider'; const USER_ROLE_MANAGER = 'manager'; const USER_ROLE_CUSTOMER = 'customer'; /** @var Description */ private $note; /** @var Id */ private $id; /** @var Status */ private $status; /** @var Name */ protected $firstName; /** @var Name */ protected $lastName; /** @var Birthday */ protected $birthday; /** @var Picture */ protected $picture; /** @var Id */ protected $externalId; /** @var Email */ protected $email; /** @var Phone */ protected $phone; /** @var Password */ private $password; /** @var Json */ private $usedTokens; /** @var int */ private $loginType; /** @var Name */ private $zoomUserId; /** @var Name */ private $countryPhoneIso; /** @var Json */ protected $translations; /** * AbstractUser constructor. * * @param Name $firstName * @param Name $lastName * @param Email $email */ public function __construct( Name $firstName, Name $lastName, Email $email ) { $this->firstName = $firstName; $this->lastName = $lastName; $this->email = $email; } /** * @return Id */ public function getId() { return $this->id; } /** * @param Id $id */ public function setId(Id $id) { $this->id = $id; } /** * @return Status */ public function getStatus() { return $this->status; } /** * @param Status $status */ public function setStatus(Status $status) { $this->status = $status; } /** * @return Name */ public function getFirstName() { return $this->firstName; } /** * @param Name $firstName */ public function setFirstName(Name $firstName) { $this->firstName = $firstName; } /** * @return Name */ public function getLastName() { return $this->lastName; } /** * @param Name $lastName */ public function setLastName(Name $lastName) { $this->lastName = $lastName; } /** * @return string */ public function getFullName() { return $this->firstName->getValue() . ' ' . $this->lastName->getValue(); } /** * @return Birthday */ public function getBirthday() { return $this->birthday; } /** * @param Birthday $birthday */ public function setBirthday(Birthday $birthday) { $this->birthday = $birthday; } /** * @return Picture */ public function getPicture() { return $this->picture; } /** * @param Picture $picture */ public function setPicture(Picture $picture) { $this->picture = $picture; } /** * @return ID */ public function getExternalId() { return $this->externalId; } /** * @param ID $externalId */ public function setExternalId(Id $externalId) { $this->externalId = $externalId; } /** * @return Email */ public function getEmail() { return $this->email; } /** * @param Email $email */ public function setEmail(Email $email) { $this->email = $email; } /** * @return Phone */ public function getPhone() { return $this->phone; } /** * @param Phone $phone */ public function setPhone(Phone $phone) { $this->phone = $phone; } /** * Get the user type in a string form */ public function getType() { return self::USER_ROLE_CUSTOMER; } /** * @return Description */ public function getNote() { return $this->note; } /** * @param Description $note */ public function setNote(Description $note) { $this->note = $note; } /** * @return Name */ public function getZoomUserId() { return $this->zoomUserId; } /** * @param Name $zoomUserId */ public function setZoomUserId(Name $zoomUserId) { $this->zoomUserId = $zoomUserId; } /** * @return Password */ public function getPassword() { return $this->password; } /** * @param Password $password */ public function setPassword($password) { $this->password = $password; } /** * @return Json */ public function getUsedTokens() { return $this->usedTokens; } /** * @param Json $usedTokens */ public function setUsedTokens($usedTokens) { $this->usedTokens = $usedTokens; } /** * @return int */ public function getLoginType() { return $this->loginType; } /** * @param int $loginType */ public function setLoginType($loginType) { $this->loginType = $loginType; } /** * @return Name */ public function getCountryPhoneIso() { return $this->countryPhoneIso; } /** * @param Name $countryPhoneIso */ public function setCountryPhoneIso(Name $countryPhoneIso) { $this->countryPhoneIso = $countryPhoneIso; } /** * @return Json */ public function getTranslations() { return $this->translations; } /** * @param Json $translations */ public function setTranslations(Json $translations) { $this->translations = $translations; } /** * @return array */ public function toArray() { return [ 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, 'firstName' => $this->getFirstName()->getValue(), 'lastName' => $this->getLastName()->getValue(), 'birthday' => null !== $this->getBirthday() ? $this->getBirthday()->getValue() : null, 'email' => $this->getEmail()->getValue(), 'phone' => null !== $this->getPhone() ? $this->getPhone()->getValue() : null, 'type' => $this->getType(), 'status' => null !== $this->getStatus() ? $this->getStatus()->getValue() : null, 'note' => null !== $this->getNote() ? $this->getNote()->getValue() : null, 'zoomUserId' => null !== $this->getZoomUserId() ? $this->getZoomUserId()->getValue() : null, 'countryPhoneIso' => null !== $this->getCountryPhoneIso() ? $this->getCountryPhoneIso()->getValue() : null, 'externalId' => null !== $this->getExternalId() ? $this->getExternalId()->getValue() : null, 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, // 'password' => null !== $this->getPassword() ? $this->getPassword()->getValue() : null ]; } } Entity/User/Manager.php 0000666 00000000461 15165375612 0011041 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\User; /** * Class Manager * * @package AmeliaBooking\Domain\Entity\User */ class Manager extends AbstractUser { /** * Get the user type in a string form */ public function getType() { return self::USER_ROLE_MANAGER; } } Entity/User/Provider.php 0000666 00000014256 15165375612 0011270 0 ustar 00 <?php namespace AmeliaBooking\Domain\Entity\User; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Google\GoogleCalendar; use AmeliaBooking\Domain\Entity\Outlook\OutlookCalendar; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; /** * Class Provider * * @package AmeliaBooking\Domain\Entity\User */ class Provider extends AbstractUser { /** @var Collection */ private $weekDayList; /** @var Collection */ private $serviceList; /** @var Collection */ private $dayOffList; /** @var Collection */ private $specialDayList; /** @var Collection */ private $appointmentList; /** @var Id */ private $locationId; /** @var GoogleCalendar */ private $googleCalendar; /** @var OutlookCalendar */ private $outlookCalendar; /** @var Name */ private $timeZone; /** @var Description */ private $description; /** * @param Name $firstName * @param Name $lastName * @param Email $email * @param Phone $phone * @param Collection $weekDayList * @param Collection $serviceList * @param Collection $dayOffList * @param Collection $specialDayList * @param Collection $appointmentList */ public function __construct( Name $firstName, Name $lastName, Email $email, Phone $phone, Collection $weekDayList, Collection $serviceList, Collection $dayOffList, Collection $specialDayList, Collection $appointmentList ) { parent::__construct($firstName, $lastName, $email); $this->phone = $phone; $this->weekDayList = $weekDayList; $this->serviceList = $serviceList; $this->dayOffList = $dayOffList; $this->specialDayList = $specialDayList; $this->appointmentList = $appointmentList; } /** * Get the user type in a string form */ public function getType() { return self::USER_ROLE_PROVIDER; } /** * @return Collection */ public function getWeekDayList() { return $this->weekDayList; } /** * @param Collection $weekDayList */ public function setWeekDayList(Collection $weekDayList) { $this->weekDayList = $weekDayList; } /** * @return Collection */ public function getServiceList() { return $this->serviceList; } /** * @param Collection $serviceList */ public function setServiceList(Collection $serviceList) { $this->serviceList = $serviceList; } /** * @return Collection */ public function getDayOffList() { return $this->dayOffList; } /** * @param Collection $dayOffList */ public function setDayOffList(Collection $dayOffList) { $this->dayOffList = $dayOffList; } /** * @return Collection */ public function getSpecialDayList() { return $this->specialDayList; } /** * @param Collection $specialDayList */ public function setSpecialDayList(Collection $specialDayList) { $this->specialDayList = $specialDayList; } /** * @return Collection */ public function getAppointmentList() { return $this->appointmentList; } /** * @param Collection $appointmentList */ public function setAppointmentList(Collection $appointmentList) { $this->appointmentList = $appointmentList; } /** * @return Id */ public function getLocationId() { return $this->locationId; } /** * @param Id $locationId */ public function setLocationId(Id $locationId) { $this->locationId = $locationId; } /** * @return GoogleCalendar mixed */ public function getGoogleCalendar() { return $this->googleCalendar; } /** * @param mixed $googleCalendar */ public function setGoogleCalendar($googleCalendar) { $this->googleCalendar = $googleCalendar; } /** * @return OutlookCalendar mixed */ public function getOutlookCalendar() { return $this->outlookCalendar; } /** * @param mixed $outlookCalendar */ public function setOutlookCalendar($outlookCalendar) { $this->outlookCalendar = $outlookCalendar; } /** * @return Name */ public function getTimeZone() { return $this->timeZone; } /** * @param Name $timeZone */ public function setTimeZone($timeZone) { $this->timeZone = $timeZone; } /** * @return Description */ public function getDescription() { return $this->description; } /** * @param Description $description */ public function setDescription($description) { $this->description = $description; } /** * Returns the Provider entity fields in an array form */ public function toArray() { return array_merge( parent::toArray(), [ 'phone' => $this->phone->getValue(), 'weekDayList' => $this->weekDayList->toArray(), 'serviceList' => $this->serviceList->toArray(), 'dayOffList' => $this->dayOffList->toArray(), 'specialDayList' => $this->specialDayList->toArray(), 'locationId' => $this->getLocationId() ? $this->getLocationId()->getValue() : null, 'googleCalendar' => $this->getGoogleCalendar() ? $this->getGoogleCalendar()->toArray() : null, 'outlookCalendar' => $this->getOutlookCalendar() ? $this->getOutlookCalendar()->toArray() : null, 'timeZone' => $this->getTimeZone() ? $this->getTimeZone()->getValue() : null, 'description' => $this->getDescription() ? $this->getDescription()->getValue() : null, ] ); } } Factory/User/ProviderFactory.php 0000666 00000006160 15165375612 0012746 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\User; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; /** * Class ProviderFactory * * @package AmeliaBooking\Domain\Factory\User */ class ProviderFactory extends UserFactory { /** * @param array $providers * @param array $services * @param array $providersServices * * @return Collection * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($providers, $services = [], $providersServices = []) { $providersCollection = new Collection(); foreach ($providers as $providerKey => $providerArray) { $providersCollection->addItem( self::create($providerArray), $providerKey ); if ($providersServices && array_key_exists($providerKey, $providersServices)) { foreach ((array)$providersServices[$providerKey] as $serviceKey => $providerService) { if (array_key_exists($serviceKey, $services)) { $providersCollection->getItem($providerKey)->getServiceList()->addItem( ServiceFactory::create( array_merge( $services[$serviceKey], $providerService ) ), $serviceKey ); } } } } return $providersCollection; } /** * @param array $rows * * @return array */ public static function reformat($rows) { $data = []; foreach ($rows as $row) { $id = $row['provider_id']; $googleCalendarId = $row['google_calendar_id']; if ($id && empty($data[$id])) { $data[$id] = [ 'id' => $id, 'type' => $row['provider_type'], 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'gender' => $row['provider_gender'], 'translations' => $row['provider_translations'], ]; } if ($data[$id] && $googleCalendarId && empty($data[$id]['googleCalendar'])) { $data[$id]['googleCalendar'] = [ 'id' => $row['google_calendar_id'], 'token' => $row['google_calendar_token'], 'calendarId' => isset($row['google_calendar_calendar_id']) ? $row['google_calendar_calendar_id'] : null ]; } } return $data; } } Factory/User/UserFactory.php 0000666 00000025136 15165375612 0012076 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\User; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\User\Customer; use AmeliaBooking\Domain\Entity\User\Manager; use AmeliaBooking\Domain\Entity\User\Admin; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Google\GoogleCalendarFactory; use AmeliaBooking\Domain\Factory\Outlook\OutlookCalendarFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodLocationFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodServiceFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodLocationFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodServiceFactory; use AmeliaBooking\Domain\ValueObjects\DateTime\Birthday; use AmeliaBooking\Domain\ValueObjects\Gender; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\String\Password; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Factory\Schedule\DayOffFactory; use AmeliaBooking\Domain\Factory\Schedule\TimeOutFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodFactory; use AmeliaBooking\Domain\Factory\Schedule\WeekDayFactory; /** * Class UserFactory * * @package AmeliaBooking\Domain\Factory\User */ class UserFactory { /** * @param $data * * @return Admin|Customer|Manager|Provider * @throws InvalidArgumentException */ public static function create($data) { if (!isset($data['type']) || !$data['email']) { $data['type'] = 'customer'; } switch ($data['type']) { case 'admin': $user = new Admin( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']) ); break; case 'provider': $weekDayList = []; $dayOffList = []; $specialDayList = []; $serviceList = []; $appointmentList = []; if (isset($data['weekDayList'])) { foreach ((array)$data['weekDayList'] as $weekDay) { $timeOutList = []; if (isset($weekDay['timeOutList'])) { foreach ((array)$weekDay['timeOutList'] as $timeOut) { $timeOutList[] = TimeOutFactory::create($timeOut); } $weekDay['timeOutList'] = $timeOutList; } $periodList = []; if (isset($weekDay['periodList'])) { foreach ((array)$weekDay['periodList'] as $period) { $periodServiceList = []; if (isset($period['periodServiceList'])) { foreach ((array)$period['periodServiceList'] as $periodService) { $periodServiceList[] = PeriodServiceFactory::create($periodService); } } $periodLocationList = []; if (isset($period['periodLocationList'])) { foreach ((array)$period['periodLocationList'] as $periodLocation) { $periodLocationList[] = PeriodLocationFactory::create($periodLocation); } } $period['periodServiceList'] = $periodServiceList; $period['periodLocationList'] = $periodLocationList; $periodList[] = PeriodFactory::create($period); } $weekDay['periodList'] = $periodList; } $weekDayList[] = WeekDayFactory::create($weekDay); } } if (isset($data['specialDayList'])) { foreach ((array)$data['specialDayList'] as $specialDay) { $periodList = []; if (isset($specialDay['periodList'])) { foreach ((array)$specialDay['periodList'] as $period) { $periodServiceList = []; if (isset($period['periodServiceList'])) { foreach ((array)$period['periodServiceList'] as $periodService) { $periodServiceList[] = SpecialDayPeriodServiceFactory::create($periodService); } } $periodLocationList = []; if (isset($period['periodLocationList'])) { foreach ((array)$period['periodLocationList'] as $periodLocation) { $periodLocationList[] = SpecialDayPeriodLocationFactory::create($periodLocation); } } $period['periodServiceList'] = $periodServiceList; $period['periodLocationList'] = $periodLocationList; $periodList[] = SpecialDayPeriodFactory::create($period); } $specialDay['periodList'] = $periodList; } $specialDayList[] = SpecialDayFactory::create($specialDay); } } if (isset($data['dayOffList'])) { foreach ((array)$data['dayOffList'] as $dayOff) { $dayOffList[] = DayOffFactory::create($dayOff); } } if (isset($data['serviceList'])) { foreach ((array)$data['serviceList'] as $service) { $serviceList[$service['id']] = ServiceFactory::create($service); } } $user = new Provider( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']), new Phone(isset($data['phone']) ? $data['phone'] : null), new Collection($weekDayList), new Collection($serviceList), new Collection($dayOffList), new Collection($specialDayList), new Collection($appointmentList) ); if (!empty($data['password'])) { $user->setPassword(new Password($data['password'])); } if (!empty($data['locationId'])) { $user->setLocationId(new Id($data['locationId'])); } if (!empty($data['googleCalendar']) && isset($data['googleCalendar']['token'])) { $user->setGoogleCalendar(GoogleCalendarFactory::create($data['googleCalendar'])); } if (!empty($data['outlookCalendar']) && isset($data['outlookCalendar']['token'])) { $user->setOutlookCalendar(OutlookCalendarFactory::create($data['outlookCalendar'])); } if (!empty($data['zoomUserId'])) { $user->setZoomUserId(new Name($data['zoomUserId'])); } if (!empty($data['timeZone'])) { $user->setTimeZone(new Name($data['timeZone'])); } if (!empty($data['id'])) { $user->setId(new Id($data['id'])); } if (!empty($data['translations'])) { $user->setTranslations(new Json($data['translations'])); } if (!empty($data['description'])) { $user->setDescription(new Description($data['description'])); } break; case 'manager': $user = new Manager( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']) ); break; case 'customer': default: $user = new Customer( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email'] ?: null), new Phone(!empty($data['phone']) ? $data['phone'] : null), new Gender(!empty($data['gender']) ? strtolower($data['gender']) : null) ); if (!empty($data['translations'])) { $user->setTranslations(new Json($data['translations'])); } break; } if (!empty($data['countryPhoneIso'])) { $user->setCountryPhoneIso(new Name($data['countryPhoneIso'])); } if (!empty($data['birthday'])) { if (is_string($data['birthday'])) { $user->setBirthday(new Birthday(\DateTime::createFromFormat('Y-m-d', $data['birthday']))); } else { $user->setBirthday(new Birthday($data['birthday'])); } } if (!empty($data['id'])) { $user->setId(new Id($data['id'])); } if (!empty($data['externalId'])) { $user->setExternalId(new Id($data['externalId'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $user->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['status'])) { $user->setStatus(new Status($data['status'])); } if (!empty($data['note'])) { $user->setNote(new Description($data['note'])); } return $user; } } Factory/Schedule/SpecialDayPeriodFactory.php 0000666 00000002317 15165375612 0015153 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriod; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class SpecialDayPeriodFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class SpecialDayPeriodFactory { /** * @param array $data * * @return SpecialDayPeriod * @throws InvalidArgumentException */ public static function create($data) { $period = new SpecialDayPeriod( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection($data['periodServiceList']), new Collection($data['periodLocationList']) ); if (isset($data['id'])) { $period->setId(new Id($data['id'])); } if (isset($data['locationId'])) { $period->setLocationId(new Id($data['locationId'])); } return $period; } } Factory/Schedule/TimeOutFactory.php 0000666 00000001471 15165375612 0013360 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\TimeOut; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; class TimeOutFactory { /** * @param array $data * * @return TimeOut * @throws InvalidArgumentException */ public static function create($data) { $timeOut = new TimeOut( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])) ); if (isset($data['id'])) { $timeOut->setId(new Id($data['id'])); } return $timeOut; } } Factory/Schedule/SpecialDayFactory.php 0000666 00000002155 15165375612 0014010 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\SpecialDay; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\Collection\Collection; /** * Class SpecialDayFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class SpecialDayFactory { /** * @param array $data * * @return SpecialDay * @throws InvalidArgumentException */ public static function create($data) { $specialDay = new SpecialDay( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['startDate'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])), new Collection(isset($data['periodList']) ? $data['periodList'] : []) ); if (isset($data['id'])) { $specialDay->setId(new Id($data['id'])); } return $specialDay; } } Factory/Schedule/PeriodServiceFactory.php 0000666 00000001060 15165375612 0014527 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class PeriodServiceFactory { /** * @param array $data * * @return PeriodService */ public static function create($data) { $periodService = new PeriodService( new Id($data['serviceId']) ); if (isset($data['id'])) { $periodService->setId(new Id($data['id'])); } return $periodService; } } Factory/Schedule/DayOffFactory.php 0000666 00000002220 15165375612 0013133 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\DayOff; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\DateRepeat; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class DayOffFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class DayOffFactory { /** * @param array $data * * @return DayOff * @throws InvalidArgumentException */ public static function create($data) { $dayOff = new DayOff( new Name($data['name']), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['startDate'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])), new DateRepeat($data['repeat']) ); if (isset($data['id'])) { $dayOff->setId(new Id($data['id'])); } return $dayOff; } } Factory/Schedule/WeekDayFactory.php 0000666 00000002332 15165375612 0013320 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\WeekDay; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\Collection\Collection; /** * Class WeekDayFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class WeekDayFactory { /** * @param array $data * * @return WeekDay * @throws InvalidArgumentException */ public static function create($data) { $weekDay = new WeekDay( new IntegerValue($data['dayIndex']), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection(isset($data['timeOutList']) ? $data['timeOutList'] : []), new Collection(isset($data['periodList']) ? $data['periodList'] : []) ); if (isset($data['id'])) { $weekDay->setId(new Id($data['id'])); } return $weekDay; } } Factory/Schedule/SpecialDayPeriodLocationFactory.php 0000666 00000001102 15165375612 0016633 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class SpecialDayPeriodLocationFactory { /** * @param array $data * * @return PeriodLocation */ public static function create($data) { $periodLocation = new PeriodLocation( new Id($data['locationId']) ); if (isset($data['id'])) { $periodLocation->setId(new Id($data['id'])); } return $periodLocation; } } Factory/Schedule/SpecialDayPeriodServiceFactory.php 0000666 00000001072 15165375612 0016471 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class SpecialDayPeriodServiceFactory { /** * @param array $data * * @return PeriodService */ public static function create($data) { $periodService = new PeriodService( new Id($data['serviceId']) ); if (isset($data['id'])) { $periodService->setId(new Id($data['id'])); } return $periodService; } } Factory/Schedule/PeriodLocationFactory.php 0000666 00000001070 15165375612 0014700 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class PeriodLocationFactory { /** * @param array $data * * @return PeriodLocation */ public static function create($data) { $periodLocation = new PeriodLocation( new Id($data['locationId']) ); if (isset($data['id'])) { $periodLocation->setId(new Id($data['id'])); } return $periodLocation; } } Factory/Schedule/PeriodFactory.php 0000666 00000002235 15165375612 0013213 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Schedule\Period; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class PeriodFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class PeriodFactory { /** * @param array $data * * @return Period * @throws InvalidArgumentException */ public static function create($data) { $period = new Period( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection($data['periodServiceList']), new Collection($data['periodLocationList']) ); if (isset($data['id'])) { $period->setId(new Id($data['id'])); } if (isset($data['locationId'])) { $period->setLocationId(new Id($data['locationId'])); } return $period; } } Factory/Google/GoogleCalendarFactory.php 0000666 00000001652 15165375612 0014321 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Google; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Google\GoogleCalendar; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class GoogleCalendarFactory * * @package AmeliaBooking\Domain\Factory\Google */ class GoogleCalendarFactory { /** * @param $data * * @return GoogleCalendar * @throws InvalidArgumentException */ public static function create($data) { $googleCalendar = new GoogleCalendar( new Token($data['token']), new Name(empty($data['calendarId']) ? null : $data['calendarId']) ); if (isset($data['id'])) { $googleCalendar->setId(new Id($data['id'])); } return $googleCalendar; } } Factory/Booking/SlotsEntitiesFactory.php 0000666 00000000727 15165375612 0014442 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking; use AmeliaBooking\Domain\Entity\Booking\SlotsEntities; /** * Class SlotsEntitiesFactory * * @package AmeliaBooking\Domain\Factory\Booking */ class SlotsEntitiesFactory { /** * @return SlotsEntities */ public static function create() { return new SlotsEntities(); } } Factory/Booking/Appointment/CustomerBookingFactory.php 0000666 00000023104 15165375612 0017233 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomerService; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Factory\Bookable\Service\PackageCustomerServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\CustomerBookingEventTicketFactory; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\Factory\Payment\PaymentFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class CustomerBookingFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class CustomerBookingFactory { /** * @param $data * * @return CustomerBooking * @throws InvalidArgumentException */ public static function create($data) { $customerBooking = new CustomerBooking( new Id($data['customerId']), new BookingStatus($data['status']), new IntegerValue($data['persons']) ); if (isset($data['id'])) { $customerBooking->setId(new Id($data['id'])); } if (isset($data['price'])) { $customerBooking->setPrice(new Price($data['price'])); } if (isset($data['appointmentId'])) { $customerBooking->setAppointmentId(new Id($data['appointmentId'])); } if (isset($data['couponId'])) { $customerBooking->setCouponId(new Id($data['couponId'])); } if (isset($data['coupon'])) { $customerBooking->setCoupon(CouponFactory::create($data['coupon'])); } if (isset($data['customer'])) { $customerBooking->setCustomer(UserFactory::create($data['customer'])); } if (isset($data['customFields'])) { $customerBooking->setCustomFields(new Json($data['customFields'])); } if (isset($data['info'])) { $customerBooking->setInfo(new Json($data['info'])); } if (isset($data['utcOffset'])) { $customerBooking->setUtcOffset(new IntegerValue($data['utcOffset'])); } if (isset($data['aggregatedPrice'])) { $customerBooking->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['isChangedStatus'])) { $customerBooking->setChangedStatus(new BooleanValueObject($data['isChangedStatus'])); } if (isset($data['isLastBooking'])) { $customerBooking->setLastBooking(new BooleanValueObject($data['isLastBooking'])); } if (isset($data['deposit'])) { $customerBooking->setDeposit(new BooleanValueObject($data['deposit'])); } if (isset($data['packageCustomerService'])) { /** @var PackageCustomerService $packageCustomerService */ $packageCustomerService = PackageCustomerServiceFactory::create($data['packageCustomerService']); $customerBooking->setPackageCustomerService($packageCustomerService); } if (isset($data['duration'])) { $customerBooking->setDuration(new PositiveDuration($data['duration'])); } $payments = new Collection(); if (isset($data['payments'])) { foreach ((array)$data['payments'] as $key => $value) { $payments->addItem( PaymentFactory::create($value), $key ); } } $customerBooking->setPayments($payments); $extras = new Collection(); if (isset($data['extras'])) { foreach ((array)$data['extras'] as $key => $value) { $extras->addItem( CustomerBookingExtraFactory::create($value), $key ); } } $customerBooking->setExtras($extras); if (isset($data['token'])) { $customerBooking->setToken(new Token($data['token'])); } $ticketsBooking = new Collection(); if (!empty($data['ticketsData'])) { foreach ((array)$data['ticketsData'] as $key => $value) { $ticketsBooking->addItem( CustomerBookingEventTicketFactory::create($value), $key ); } } $customerBooking->setTicketsBooking($ticketsBooking); if (!empty($data['created'])) { $customerBooking->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } return $customerBooking; } /** * @param array $rows * * @return array */ public static function reformat($rows) { $data = []; foreach ($rows as $row) { $id = $row['booking_id']; $customerId = !empty($row['customer_id']) ? $row['customer_id'] : null; $paymentId = !empty($row['payment_id']) ? $row['payment_id'] : null; $couponId = !empty($row['coupon_id']) ? $row['coupon_id'] : null; $bookingEventTicketId = !empty($row['booking_ticket_id']) ? $row['booking_ticket_id'] : null; if ($id && empty($data[$id])) { $data[$id] = [ 'id' => $id, 'appointmentId' => $row['booking_appointmentId'], 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'couponId' => $row['booking_couponId'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => $row['booking_utcOffset'], 'aggregatedPrice' => $row['booking_aggregatedPrice'], 'duration' => !empty($row['booking_duration']) ? $row['booking_duration'] : null, ]; } if ($data[$id] && $customerId && empty($data[$id]['customer'])) { $data[$id]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'birthday' => $row['customer_birthday'], ]; } if ($data[$id] && $paymentId && empty($data[$id]['payments'][$paymentId])) { $data[$id]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $id, 'amount' => $row['payment_amount'], 'dateTime' => $row['payment_dateTime'], 'status' => $row['payment_status'], 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, ]; } if ($data[$id] && $couponId && empty($data[$id]['coupon'])) { $data[$id]['coupon'] = [ 'id' => $couponId, 'code' => $row['coupon_code'], 'discount' => $row['coupon_discount'], 'deduction' => $row['coupon_deduction'], 'limit' => $row['coupon_limit'], 'customerLimit' => $row['coupon_customerLimit'], 'status' => $row['coupon_status'], ]; } if ($data[$id] && $bookingEventTicketId && empty($data[$id]['ticketsData'][$bookingEventTicketId])) { $data[$id]['ticketsData'][$bookingEventTicketId] = [ 'id' => $bookingEventTicketId, 'eventTicketId' => $row['booking_ticket_eventTicketId'], 'customerBookingId' => $id, 'persons' => $row['booking_ticket_persons'], 'price' => $row['booking_ticket_price'], ]; } } return $data; } } Factory/Booking/Appointment/CustomerBookingExtraFactory.php 0000666 00000003074 15165375612 0020243 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBookingExtra; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; /** * Class CustomerBookingExtraFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class CustomerBookingExtraFactory { /** * @param $data * * @return CustomerBookingExtra * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $customerBookingExtra = new CustomerBookingExtra( new Id($data['extraId']), new PositiveInteger($data['quantity']) ); if (isset($data['id'])) { $customerBookingExtra->setId(new Id($data['id'])); } if (isset($data['customerBookingId'])) { $customerBookingExtra->setCustomerBookingId(new Id($data['customerBookingId'])); } if (isset($data['price'])) { $customerBookingExtra->setPrice(new Price($data['price'])); } if (isset($data['aggregatedPrice'])) { $customerBookingExtra->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } return $customerBookingExtra; } } Factory/Booking/Appointment/AppointmentFactory.php 0000666 00000037704 15165375612 0016432 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\Factory\Zoom\ZoomFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class AppointmentFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class AppointmentFactory { /** * @param $data * * @return Appointment * @throws InvalidArgumentException */ public static function create($data) { $appointment = new Appointment( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingStart'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingEnd'])), $data['notifyParticipants'], new Id($data['serviceId']), new Id($data['providerId']) ); if (!empty($data['id'])) { $appointment->setId(new Id($data['id'])); } if (!empty($data['parentId'])) { $appointment->setParentId(new Id($data['parentId'])); } if (!empty($data['locationId'])) { $appointment->setLocationId(new Id($data['locationId'])); } if (isset($data['internalNotes'])) { $appointment->setInternalNotes(new Description($data['internalNotes'])); } if (isset($data['status'])) { $appointment->setStatus(new BookingStatus($data['status'])); } if (isset($data['provider'])) { $appointment->setProvider(UserFactory::create($data['provider'])); } if (isset($data['service'])) { $appointment->setService(ServiceFactory::create($data['service'])); } if (!empty($data['googleCalendarEventId'])) { $appointment->setGoogleCalendarEventId(new Token($data['googleCalendarEventId'])); } if (!empty($data['googleMeetUrl'])) { $appointment->setGoogleMeetUrl($data['googleMeetUrl']); } if (!empty($data['outlookCalendarEventId'])) { $appointment->setOutlookCalendarEventId(new Label($data['outlookCalendarEventId'])); } if (!empty($data['zoomMeeting']['id'])) { $zoomMeeting = ZoomFactory::create( $data['zoomMeeting'] ); $appointment->setZoomMeeting($zoomMeeting); } if (isset($data['lessonSpace']) && !empty($data['lessonSpace'])) { $appointment->setLessonSpace($data['lessonSpace']); } if (isset($data['isRescheduled'])) { $appointment->setRescheduled(new BooleanValueObject($data['isRescheduled'])); } $bookings = new Collection(); if (isset($data['bookings'])) { foreach ((array)$data['bookings'] as $key => $value) { $bookings->addItem( CustomerBookingFactory::create($value), $key ); } } $appointment->setBookings($bookings); return $appointment; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $appointments = []; foreach ($rows as $row) { $appointmentId = $row['appointment_id']; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $bookingExtraId = isset($row['bookingExtra_id']) ? $row['bookingExtra_id'] : null; $paymentId = isset($row['payment_id']) ? $row['payment_id'] : null; $couponId = isset($row['coupon_id']) ? $row['coupon_id'] : null; $customerId = isset($row['customer_id']) ? $row['customer_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $serviceId = isset($row['service_id']) ? $row['service_id'] : null; if (!array_key_exists($appointmentId, $appointments)) { $zoomMeetingJson = !empty($row['appointment_zoom_meeting']) ? json_decode($row['appointment_zoom_meeting'], true) : null; $appointments[$appointmentId] = [ 'id' => $appointmentId, 'parentId' => isset($row['appointment_parentId']) ? $row['appointment_parentId'] : null, 'bookingStart' => DateTimeService::getCustomDateTimeFromUtc( $row['appointment_bookingStart'] ), 'bookingEnd' => DateTimeService::getCustomDateTimeFromUtc( $row['appointment_bookingEnd'] ), 'notifyParticipants' => isset($row['appointment_notifyParticipants']) ? $row['appointment_notifyParticipants'] : null, 'serviceId' => $row['appointment_serviceId'], 'providerId' => $row['appointment_providerId'], 'locationId' => isset($row['appointment_locationId']) ? $row['appointment_locationId'] : null, 'internalNotes' => isset($row['appointment_internalNotes']) ? $row['appointment_internalNotes'] : null, 'status' => $row['appointment_status'], 'googleCalendarEventId' => isset($row['appointment_google_calendar_event_id']) ? $row['appointment_google_calendar_event_id'] : null, 'googleMeetUrl' => isset($row['appointment_google_meet_url']) ? $row['appointment_google_meet_url'] : null, 'outlookCalendarEventId' => isset($row['appointment_outlook_calendar_event_id']) ? $row['appointment_outlook_calendar_event_id'] : null, 'zoomMeeting' => [ 'id' => $zoomMeetingJson ? $zoomMeetingJson['id'] : null, 'startUrl' => $zoomMeetingJson ? $zoomMeetingJson['startUrl'] : null, 'joinUrl' => $zoomMeetingJson ? $zoomMeetingJson['joinUrl'] : null, ], 'lessonSpace' => $row['appointment_lesson_space'], ]; } if ($bookingId && !isset($appointments[$appointmentId]['bookings'][$bookingId])) { $appointments[$appointmentId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => $appointmentId, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'couponId' => $couponId, 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => isset($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => isset($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null, 'aggregatedPrice' => isset($row['booking_aggregatedPrice']) ? $row['booking_aggregatedPrice'] : null, 'packageCustomerService' => !empty($row['booking_packageCustomerServiceId']) ? [ 'id' => $row['booking_packageCustomerServiceId'], 'serviceId' => !empty($row['package_customer_service_serviceId']) ? $row['package_customer_service_serviceId'] : null, 'bookingsCount' => !empty($row['package_customer_service_bookingsCount']) ? $row['package_customer_service_bookingsCount'] : null, 'packageCustomer' => [ 'id' => !empty($row['package_customer_id']) ? $row['package_customer_id'] : null, 'packageId' => !empty($row['package_customer_packageId']) ? $row['package_customer_packageId'] : null, 'price' => !empty($row['package_customer_price']) ? $row['package_customer_price'] : null, 'couponId' => !empty($row['package_customer_couponId']) ? $row['package_customer_couponId'] : null, ] ] : null, 'duration' => isset($row['booking_duration']) ? $row['booking_duration'] : null, 'created' => !empty($row['booking_created']) ? DateTimeService::getCustomDateTimeFromUtc($row['booking_created']) : null, ]; } if ($bookingId && $bookingExtraId) { $appointments[$appointmentId]['bookings'][$bookingId]['extras'][$bookingExtraId] = [ 'id' => $bookingExtraId, 'customerBookingId' => $bookingId, 'extraId' => $row['bookingExtra_extraId'], 'quantity' => $row['bookingExtra_quantity'], 'price' => $row['bookingExtra_price'], 'aggregatedPrice' => $row['bookingExtra_aggregatedPrice'] ]; } if ($bookingId && $paymentId) { $appointments[$appointmentId]['bookings'][$bookingId]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $bookingId, 'packageCustomerId' => !empty($row['payment_packageCustomerId']) ? $row['payment_packageCustomerId'] : null, 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, 'created' => !empty($row['payment_created']) ? $row['payment_created'] : null, ]; } if ($bookingId && $couponId) { $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['id'] = $couponId; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['code'] = $row['coupon_code']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['discount'] = $row['coupon_discount']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['deduction'] = $row['coupon_deduction']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['limit'] = $row['coupon_limit']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['customerLimit'] = $row['coupon_customerLimit']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['status'] = $row['coupon_status']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['expirationDate'] = $row['coupon_expirationDate']; } if ($bookingId && $customerId) { $appointments[$appointmentId]['bookings'][$bookingId]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'status' => $row['customer_status'], 'type' => 'customer', ]; } if ($bookingId && $providerId) { $appointments[$appointmentId]['provider'] = [ 'id' => $providerId, 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'gender' => $row['provider_gender'], 'timeZone' => !empty($row['provider_timeZone']) ? $row['provider_timeZone'] : null, 'type' => 'provider', ]; } if ($serviceId) { $appointments[$appointmentId]['service']['id'] = $row['service_id']; $appointments[$appointmentId]['service']['name'] = $row['service_name']; $appointments[$appointmentId]['service']['description'] = $row['service_description']; $appointments[$appointmentId]['service']['color'] = $row['service_color']; $appointments[$appointmentId]['service']['price'] = $row['service_price']; $appointments[$appointmentId]['service']['status'] = $row['service_status']; $appointments[$appointmentId]['service']['categoryId'] = $row['service_categoryId']; $appointments[$appointmentId]['service']['minCapacity'] = $row['service_minCapacity']; $appointments[$appointmentId]['service']['maxCapacity'] = $row['service_maxCapacity']; $appointments[$appointmentId]['service']['duration'] = $row['service_duration']; $appointments[$appointmentId]['service']['timeBefore'] = isset($row['service_timeBefore']) ? $row['service_timeBefore'] : null; $appointments[$appointmentId]['service']['timeAfter'] = isset($row['service_timeAfter']) ? $row['service_timeAfter'] : null; $appointments[$appointmentId]['service']['aggregatedPrice'] = isset($row['service_aggregatedPrice']) ? $row['service_aggregatedPrice'] : null; $appointments[$appointmentId]['service']['settings'] = isset($row['service_settings']) ? $row['service_settings'] : null; } } $collection = new Collection(); foreach ($appointments as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Factory/Booking/Event/CustomerBookingEventPeriodFactory.php 0000666 00000002157 15165375612 0020170 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventPeriod; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class CustomerBookingEventPeriodFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class CustomerBookingEventPeriodFactory { /** * @param $data * * @return CustomerBookingEventPeriod */ public static function create($data) { $customerBookingEventPeriod = new CustomerBookingEventPeriod(); if (!empty($data['id'])) { $customerBookingEventPeriod->setId(new Id($data['id'])); } if (!empty($data['eventPeriodId'])) { $customerBookingEventPeriod->setEventPeriodId(new Id($data['eventPeriodId'])); } if (!empty($data['customerBookingId'])) { $customerBookingEventPeriod->setCustomerBookingId(new Id($data['customerBookingId'])); } return $customerBookingEventPeriod; } } Factory/Booking/Event/EventTicketFactory.php 0000666 00000003776 15165375612 0015146 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\EventTicket; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class EventTicketFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventTicketFactory { /** * @param $data * * @return EventTicket * @throws InvalidArgumentException */ public static function create($data) { $eventTicket = new EventTicket(); if (isset($data['id'])) { $eventTicket->setId(new Id($data['id'])); } if (isset($data['eventId'])) { $eventTicket->setEventId(new Id($data['eventId'])); } if (isset($data['name'])) { $eventTicket->setName(new Name($data['name'])); } if (isset($data['enabled'])) { $eventTicket->setEnabled(new BooleanValueObject($data['enabled'])); } if (isset($data['price'])) { $eventTicket->setPrice(new Price($data['price'])); } if (isset($data['spots'])) { $eventTicket->setSpots(new IntegerValue($data['spots'])); } if (isset($data['dateRanges'])) { $eventTicket->setDateRanges(new Json($data['dateRanges'])); } if (isset($data['sold'])) { $eventTicket->setSold(new IntegerValue($data['sold'])); } if (!empty($data['translations'])) { $eventTicket->setTranslations(new Json($data['translations'])); } return $eventTicket; } } Factory/Booking/Event/RecurringFactory.php 0000666 00000003534 15165375612 0014651 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\Recurring; use AmeliaBooking\Domain\ValueObjects\String\Cycle; /** * Class RecurringFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class RecurringFactory { /** * @param $data * * @return Recurring * @throws InvalidArgumentException */ public static function create($data) { $recurring = new Recurring(new Cycle($data['cycle'])); if (isset($data['order'])) { $recurring->setOrder(new WholeNumber($data['order'])); } if (isset($data['cycleInterval'])) { $recurring->setCycleInterval(new WholeNumber($data['cycleInterval'])); } if (isset($data['monthlyRepeat'])) { $recurring->setMonthlyRepeat($data['monthlyRepeat']); } if (isset($data['monthlyOnRepeat']) && isset($data['monthlyOnDay'])) { $recurring->setMonthlyOnRepeat(strtolower($data['monthlyOnRepeat'])); $recurring->setMonthlyOnDay(strtolower($data['monthlyOnDay'])); } if (isset($data['monthDate'])) { $recurring->setMonthDate($data['monthDate'] ? new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['monthDate'])) : null); } if (isset($data['until'])) { $recurring->setUntil(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['until']))); } return $recurring; } } Factory/Booking/Event/EventFactory.php 0000666 00000064121 15165375612 0013771 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\Event; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Factory\Booking\Appointment\CustomerBookingFactory; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\Factory\User\ProviderFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class EventFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventFactory { /** * @param $data * * @return Event * @throws InvalidArgumentException */ public static function create($data) { $event = new Event(); if (isset($data['id'])) { $event->setId(new Id($data['id'])); } if (isset($data['name'])) { $event->setName(new Name($data['name'])); } if (isset($data['price'])) { $event->setPrice(new Price($data['price'])); } if (isset($data['parentId'])) { $event->setParentId(new Id($data['parentId'])); } if (!empty($data['bookingOpens'])) { $event->setBookingOpens(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingOpens']))); } if (!empty($data['bookingCloses'])) { $event->setBookingCloses(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingCloses']))); } if (!empty($data['bookingOpensRec'])) { $event->setBookingOpensRec($data['bookingOpensRec']); } if (!empty($data['bookingClosesRec'])) { $event->setBookingClosesRec($data['bookingClosesRec']); } if (!empty($data['ticketRangeRec'])) { $event->setTicketRangeRec($data['ticketRangeRec']); } if (isset($data['notifyParticipants'])) { $event->setNotifyParticipants($data['notifyParticipants']); } if (isset($data['status'])) { $event->setStatus(new BookingStatus($data['status'])); } if (isset($data['recurring']['cycle'], $data['recurring']['until'])) { $event->setRecurring(RecurringFactory::create($data['recurring'])); } if (isset($data['bringingAnyone'])) { $event->setBringingAnyone(new BooleanValueObject($data['bringingAnyone'])); } if (isset($data['bookMultipleTimes'])) { $event->setBookMultipleTimes(new BooleanValueObject($data['bookMultipleTimes'])); } if (isset($data['maxCapacity'])) { $event->setMaxCapacity(new IntegerValue($data['maxCapacity'])); } if (isset($data['maxCustomCapacity'])) { $event->setMaxCustomCapacity(new IntegerValue($data['maxCustomCapacity'])); } if (isset($data['description'])) { $event->setDescription(new Description($data['description'])); } if (!empty($data['locationId'])) { $event->setLocationId(new Id($data['locationId'])); } if (!empty($data['customLocation'])) { $event->setCustomLocation(new Name($data['customLocation'])); } if (isset($data['color'])) { $event->setColor(new Color($data['color'])); } if (isset($data['show'])) { $event->setShow(new BooleanValueObject($data['show'])); } if (isset($data['created'])) { $event->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } if (!empty($data['settings'])) { $event->setSettings(new Json($data['settings'])); } if (isset($data['deposit'])) { $event->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $event->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['fullPayment'])) { $event->setFullPayment(new BooleanValueObject($data['fullPayment'])); } if (isset($data['customPricing'])) { $event->setCustomPricing(new BooleanValueObject($data['customPricing'])); } if (isset($data['depositPerPerson'])) { $event->setDepositPerPerson(new BooleanValueObject($data['depositPerPerson'])); } if (isset($data['closeAfterMin'])) { $event->setCloseAfterMin(new IntegerValue($data['closeAfterMin'])); } if (isset($data['closeAfterMinBookings'])) { $event->setCloseAfterMinBookings(new BooleanValueObject($data['closeAfterMinBookings'])); } if (isset($data['aggregatedPrice'])) { $event->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['maxExtraPeople'])) { $event->setMaxExtraPeople(new IntegerValue($data['maxExtraPeople'])); } $tickets = new Collection(); if (isset($data['customTickets'])) { foreach ($data['customTickets'] as $key => $value) { $tickets->addItem( EventTicketFactory::create($value), $key ); } } $event->setCustomTickets($tickets); $tags = new Collection(); if (isset($data['tags'])) { foreach ((array)$data['tags'] as $key => $value) { $tags->addItem( EventTagFactory::create($value), $key ); } } $event->setTags($tags); $bookings = new Collection(); if (isset($data['bookings'])) { foreach ((array)$data['bookings'] as $key => $value) { $bookings->addItem( CustomerBookingFactory::create($value), $key ); } } $event->setBookings($bookings); $periods = new Collection(); if (isset($data['periods'])) { foreach ((array)$data['periods'] as $key => $value) { $periods->addItem(EventPeriodFactory::create($value)); } } $event->setPeriods($periods); $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::EVENT), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($event->getId()) { $galleryImage->setEntityId($event->getId()); } $gallery->addItem($galleryImage); } } $event->setGallery($gallery); $coupons = new Collection(); if (!empty($data['coupons'])) { /** @var array $couponsList */ $couponsList = $data['coupons']; foreach ($couponsList as $couponKey => $coupon) { $coupons->addItem(CouponFactory::create($coupon), $couponKey); } } $event->setCoupons($coupons); $providers = new Collection(); if (!empty($data['providers'])) { /** @var array $providerList */ $providerList = $data['providers']; foreach ($providerList as $providerKey => $provider) { $providers->addItem(ProviderFactory::create($provider), $providerKey); } } if (!empty($data['organizerId'])) { $event->setOrganizerId(new Id($data['organizerId'])); } $event->setProviders($providers); if (!empty($data['zoomUserId'])) { $event->setZoomUserId(new Name($data['zoomUserId'])); } if (!empty($data['translations'])) { $event->setTranslations(new Json($data['translations'])); } return $event; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $events = []; foreach ($rows as $row) { $eventId = $row['event_id']; $eventPeriodId = isset($row['event_periodId']) ? $row['event_periodId'] : null; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $customerId = isset($row['customer_id']) ? $row['customer_id'] : null; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $bookingTicketId = isset($row['booking_ticket_id']) ? $row['booking_ticket_id'] : null; $paymentId = isset($row['payment_id']) ? $row['payment_id'] : null; $tagId = isset($row['event_tagId']) ? $row['event_tagId'] : null; $ticketId = isset($row['ticket_id']) ? $row['ticket_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $couponId = isset($row['coupon_id']) ? $row['coupon_id'] : null; if (!array_key_exists($eventId, $events)) { $events[$eventId] = [ 'id' => $eventId, 'name' => $row['event_name'], 'status' => $row['event_status'], 'bookingOpens' => $row['event_bookingOpens'] && $row['event_bookingOpens'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_bookingOpens']) : null, 'bookingCloses' => $row['event_bookingCloses'] && $row['event_bookingCloses'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_bookingCloses']) : null, 'bookingOpensRec' => isset($row['event_bookingOpensRec']) ? $row['event_bookingOpensRec'] : null, 'bookingClosesRec' => isset($row['event_bookingClosesRec']) ? $row['event_bookingClosesRec'] : null, 'ticketRangeRec' => isset($row['event_ticketRangeRec']) ? $row['event_ticketRangeRec'] : null, 'recurring' => [ 'cycle' => $row['event_recurringCycle'], 'order' => $row['event_recurringOrder'], 'cycleInterval' => $row['event_recurringInterval'], 'monthlyRepeat' => isset($row['event_recurringMonthly']) ? $row['event_recurringMonthly'] : null, 'monthDate' => !empty($row['event_monthlyDate']) && $row['event_monthlyDate'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_monthlyDate']) : null, 'monthlyOnRepeat' => isset($row['event_monthlyOnRepeat']) ? $row['event_monthlyOnRepeat'] : null, 'monthlyOnDay' => isset($row['event_monthlyOnDay']) ? $row['event_monthlyOnDay'] : null, 'until' => !empty($row['event_recurringUntil']) && $row['event_recurringUntil'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_recurringUntil']) : null, ], 'bringingAnyone' => $row['event_bringingAnyone'], 'bookMultipleTimes' => $row['event_bookMultipleTimes'], 'maxCapacity' => $row['event_maxCapacity'], 'maxCustomCapacity' => $row['event_maxCustomCapacity'], 'maxExtraPeople' => $row['event_maxExtraPeople'], 'price' => $row['event_price'], 'description' => $row['event_description'], 'color' => $row['event_color'], 'show' => $row['event_show'], 'notifyParticipants' => $row['event_notifyParticipants'], 'locationId' => $row['event_locationId'], 'customLocation' => $row['event_customLocation'], 'parentId' => $row['event_parentId'], 'created' => $row['event_created'], 'settings' => isset($row['event_settings']) ? $row['event_settings'] : null, 'zoomUserId' => isset($row['event_zoomUserId']) ? $row['event_zoomUserId'] : null, 'organizerId' => isset($row['event_organizerId']) ? $row['event_organizerId'] : null, 'translations' => isset($row['event_translations']) ? $row['event_translations'] : null, 'deposit' => isset($row['event_deposit']) ? $row['event_deposit'] : null, 'depositPayment' => isset($row['event_depositPayment']) ? $row['event_depositPayment'] : null, 'depositPerPerson' => isset($row['event_depositPerPerson']) ? $row['event_depositPerPerson'] : null, 'fullPayment' => isset($row['event_fullPayment']) ? $row['event_fullPayment'] : null, 'customPricing' => isset($row['event_customPricing']) ? $row['event_customPricing'] : null, 'closeAfterMin' => isset($row['event_closeAfterMin']) ? $row['event_closeAfterMin'] : null, 'closeAfterMinBookings' => isset($row['event_closeAfterMinBookings']) ? $row['event_closeAfterMinBookings'] : null, 'aggregatedPrice' => isset($row['event_aggregatedPrice']) ? $row['event_aggregatedPrice'] : null, ]; } if ($galleryId) { $events[$eventId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $events[$eventId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $events[$eventId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $events[$eventId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } if ($providerId) { $events[$eventId]['providers'][$providerId] = [ 'id' => $providerId, 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'pictureFullPath' => isset($row['provider_pictureFullPath']) ? $row['provider_pictureFullPath'] : null, 'pictureThumbPath' => isset($row['provider_pictureFullPath']) ? $row['provider_pictureThumbPath'] : null, 'type' => 'provider', 'googleCalendar' => [ 'id' => isset($row['google_calendar_id']) ? $row['google_calendar_id'] : null, 'token' => isset($row['google_calendar_token']) ? $row['google_calendar_token'] : null, 'calendarId' => isset($row['google_calendar_calendar_id']) ? $row['google_calendar_calendar_id'] : null ], 'translations' => $row['provider_translations'], 'timeZone' => isset($row['provider_timeZone']) ? $row['provider_timeZone'] : null, 'outlookCalendar' => [ 'id' => isset($row['outlook_calendar_id']) ? $row['outlook_calendar_id']: null, 'token' => isset($row['outlook_calendar_token']) ? $row['outlook_calendar_token'] : null, 'calendarId' => isset($row['outlook_calendar_calendar_id']) ? $row['outlook_calendar_calendar_id'] : null ], ]; } if ($eventPeriodId && !isset($events[$eventId]['periods'][$eventPeriodId])) { $zoomMeetingJson = !empty($row['event_periodZoomMeeting']) ? json_decode($row['event_periodZoomMeeting'], true) : null; $events[$eventId]['periods'][$eventPeriodId] = [ 'id' => $eventPeriodId, 'eventId' => $eventId, 'periodStart' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodStart']), 'periodEnd' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodEnd']), 'zoomMeeting' => [ 'id' => $zoomMeetingJson ? $zoomMeetingJson['id'] : null, 'startUrl' => $zoomMeetingJson ? $zoomMeetingJson['startUrl'] : null, 'joinUrl' => $zoomMeetingJson ? $zoomMeetingJson['joinUrl'] : null, ], 'lessonSpace' => !empty($row['event_periodLessonSpace']) ? $row['event_periodLessonSpace'] : null, 'bookings' => [], 'googleCalendarEventId' => !empty($row['event_googleCalendarEventId']) ? $row['event_googleCalendarEventId'] : null, 'googleMeetUrl' => !empty($row['event_googleMeetUrl']) ? $row['event_googleMeetUrl'] : null, 'outlookCalendarEventId' => !empty($row['event_outlookCalendarEventId']) ? $row['event_outlookCalendarEventId'] : null ]; } if ($tagId && !isset($events[$eventId]['tags'][$tagId])) { $events[$eventId]['tags'][$tagId] = [ 'id' => $tagId, 'eventId' => $eventId, 'name' => $row['event_tagName'] ]; } if ($bookingId && !isset($events[$eventId]['bookings'][$bookingId])) { $events[$eventId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => null, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null, 'aggregatedPrice' => isset($row['booking_aggregatedPrice']) ? $row['booking_aggregatedPrice'] : null, 'token' => isset($row['booking_token']) ? $row['booking_token'] : null, ]; } if ($bookingTicketId && !isset($events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId])) { $events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId] = [ 'id' => $bookingTicketId, 'eventTicketId' => $row['booking_ticket_eventTicketId'], 'customerBookingId' => $bookingId, 'persons' => $row['booking_ticket_persons'], 'price' => $row['booking_ticket_price'], ]; } if ($ticketId && !isset($events[$eventId]['customTickets'][$ticketId])) { $events[$eventId]['customTickets'][$ticketId] = [ 'id' => $ticketId, 'eventId' => $eventId, 'name' => $row['ticket_name'], 'enabled' => $row['ticket_enabled'], 'spots' => $row['ticket_spots'], 'price' => $row['ticket_price'], 'dateRanges' => $row['ticket_dateRanges'], 'translations' => $row['ticket_translations'], ]; } if ($bookingId && !isset($events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId])) { $events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => null, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null ]; } if ($bookingId && $paymentId) { $events[$eventId]['bookings'][$bookingId]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $bookingId, 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, ]; } if ($bookingId && $customerId) { $events[$eventId]['bookings'][$bookingId]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'birthday' => !empty($row['customer_birthday']) ? $row['customer_birthday'] : null, 'type' => 'customer', ]; } if ($bookingId && $couponId) { $events[$eventId]['bookings'][$bookingId]['coupon']['id'] = $couponId; $events[$eventId]['bookings'][$bookingId]['coupon']['code'] = $row['coupon_code']; $events[$eventId]['bookings'][$bookingId]['coupon']['discount'] = $row['coupon_discount']; $events[$eventId]['bookings'][$bookingId]['coupon']['deduction'] = $row['coupon_deduction']; $events[$eventId]['bookings'][$bookingId]['coupon']['limit'] = $row['coupon_limit']; $events[$eventId]['bookings'][$bookingId]['coupon']['customerLimit'] = $row['coupon_customerLimit']; $events[$eventId]['bookings'][$bookingId]['coupon']['status'] = $row['coupon_status']; } if ($couponId) { $events[$eventId]['coupons'][$couponId]['id'] = $couponId; $events[$eventId]['coupons'][$couponId]['code'] = $row['coupon_code']; $events[$eventId]['coupons'][$couponId]['discount'] = $row['coupon_discount']; $events[$eventId]['coupons'][$couponId]['deduction'] = $row['coupon_deduction']; $events[$eventId]['coupons'][$couponId]['limit'] = $row['coupon_limit']; $events[$eventId]['coupons'][$couponId]['customerLimit'] = $row['coupon_customerLimit']; $events[$eventId]['coupons'][$couponId]['status'] = $row['coupon_status']; } } $collection = new Collection(); foreach ($events as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Factory/Booking/Event/EventTagFactory.php 0000666 00000002006 15165375612 0014417 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Entity\Booking\Event\EventTag; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class EventTagFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventTagFactory { /** * @param $data * * @return EventTag * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $eventTag = new EventTag(); if (!empty($data['id'])) { $eventTag->setId(new Id($data['id'])); } if (!empty($data['eventId'])) { $eventTag->setEventId(new Id($data['eventId'])); } if (isset($data['name'])) { $eventTag->setName(new Name($data['name'])); } return $eventTag; } } Factory/Booking/Event/EventPeriodFactory.php 0000666 00000004634 15165375612 0015137 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\EventPeriod; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Url; use AmeliaBooking\Domain\Factory\Zoom\ZoomFactory; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class EventPeriodFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventPeriodFactory { /** * @param $data * * @return EventPeriod * @throws InvalidArgumentException */ public static function create($data) { $eventPeriod = new EventPeriod(); if (!empty($data['id'])) { $eventPeriod->setId(new Id($data['id'])); } if (!empty($data['eventId'])) { $eventPeriod->setEventId(new Id($data['eventId'])); } if (isset($data['periodStart'])) { $eventPeriod->setPeriodStart(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['periodStart']))); } if (isset($data['periodEnd'])) { $eventPeriod->setPeriodEnd(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['periodEnd']))); } if (!empty($data['zoomMeeting']) && !empty($data['zoomMeeting']['id'])) { $zoomMeeting = ZoomFactory::create( $data['zoomMeeting'] ); $eventPeriod->setZoomMeeting($zoomMeeting); } if (isset($data['lessonSpace']) && !empty($data['lessonSpace'])) { $eventPeriod->setLessonSpace($data['lessonSpace']); } if (!empty($data['googleCalendarEventId'])) { $eventPeriod->setGoogleCalendarEventId(new Token($data['googleCalendarEventId'])); } if (!empty($data['googleMeetUrl'])) { $eventPeriod->setGoogleMeetUrl($data['googleMeetUrl']); } if (!empty($data['outlookCalendarEventId'])) { $eventPeriod->setOutlookCalendarEventId(new Label($data['outlookCalendarEventId'])); } return $eventPeriod; } } Factory/Booking/Event/CustomerBookingEventTicketFactory.php 0000666 00000003143 15165375612 0020165 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventTicket; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; /** * Class CustomerBookingEventTicketFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class CustomerBookingEventTicketFactory { /** * @param $data * * @return CustomerBookingEventTicket * @throws InvalidArgumentException */ public static function create($data) { $customerBookingEventTicket = new CustomerBookingEventTicket(); if (!empty($data['id'])) { $customerBookingEventTicket->setId(new Id($data['id'])); } if (!empty($data['eventTicketId'])) { $customerBookingEventTicket->setEventTicketId(new Id($data['eventTicketId'])); } if (!empty($data['customerBookingId'])) { $customerBookingEventTicket->setCustomerBookingId(new Id($data['customerBookingId'])); } if (!empty($data['persons'])) { $customerBookingEventTicket->setPersons(new IntegerValue($data['persons'])); } if (isset($data['price'])) { $customerBookingEventTicket->setPrice(new Price($data['price'])); } return $customerBookingEventTicket; } } Factory/Payment/PaymentGatewayFactory.php 0000666 00000001311 15165375612 0014603 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Payment; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Payment\PaymentGateway; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class PaymentGatewayFactory * * @package AmeliaBooking\Domain\Factory\Payment */ class PaymentGatewayFactory { /** * @param $data * * @return PaymentGateway * @throws InvalidArgumentException */ public static function create($data) { return new PaymentGateway( new Name($data['name']) ); } } Factory/Payment/PaymentFactory.php 0000666 00000007160 15165375612 0013271 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Payment; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Payment\PaymentGateway; use AmeliaBooking\Domain\Entity\Payment\Payment; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\PaymentStatus; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\PaymentData; use AmeliaBooking\Domain\ValueObjects\String\Url; use AmeliaBooking\Infrastructure\WP\HelperService\HelperService; use AmeliaBooking\Infrastructure\WP\Integrations\WooCommerce\WooCommerceService; /** * Class PaymentFactory * * @package AmeliaBooking\Domain\Factory\Payment */ class PaymentFactory { /** * @param $data * * @return Payment * @throws InvalidArgumentException */ public static function create($data) { if (isset($data['data']) && !is_string($data['data'])) { $data['data'] = json_encode($data['data'], true); } $payment = new Payment( new Id($data['customerBookingId']), new Price($data['amount']), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['dateTime'])), new PaymentStatus($data['status']), new PaymentGateway(new Name($data['gateway'])), new PaymentData(isset($data['data']) ? $data['data'] : '') ); if (isset($data['id'])) { $payment->setId(new Id($data['id'])); } if (!empty($data['gatewayTitle'])) { $payment->setGatewayTitle(new Name($data['gatewayTitle'])); } if (!empty($data['packageCustomerId'])) { $payment->setPackageCustomerId(new Id($data['packageCustomerId'])); } if (!empty($data['parentId'])) { $payment->setParentId(new Id($data['parentId'])); } if (!empty($data['entity'])) { $payment->setEntity(new Name($data['entity'])); } if (!empty($data['actionsCompleted'])) { $payment->setActionsCompleted(new BooleanValueObject($data['actionsCompleted'])); } if (!empty($data['created'])) { $payment->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } if (!empty($data['wcOrderId']) && WooCommerceService::isEnabled()) { $payment->setWcOrderId(new Id($data['wcOrderId'])); if ($wcOrderUrl = HelperService::getWooCommerceOrderUrl($data['wcOrderId'])) { $payment->setWcOrderUrl(new Url($wcOrderUrl)); } if ($wcOrderItemValues = HelperService::getWooCommerceOrderItemAmountValues($data['wcOrderId'])) { if (!empty($wcOrderItemValues[0]['coupon'])) { $payment->setWcItemCouponValue(new Price($wcOrderItemValues[0]['coupon'] < 0 ? 0 : $wcOrderItemValues[0]['coupon'])); } if (!empty($wcOrderItemValues[0]['tax'])) { $payment->setWcItemTaxValue(new Price($wcOrderItemValues[0]['tax'])); } } } if (!empty($data['transactionId'])) { $payment->setTransactionId($data['transactionId']); } return $payment; } } Factory/Settings/SettingsFactory.php 0000666 00000010242 15165375612 0013632 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Settings; use AmeliaBooking\Domain\Entity\Settings\GeneralSettings; use AmeliaBooking\Domain\Entity\Settings\LessonSpaceSettings; use AmeliaBooking\Domain\Entity\Settings\PaymentSettings; use AmeliaBooking\Domain\Entity\Settings\Settings; use AmeliaBooking\Domain\Entity\Settings\ZoomSettings; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class SettingsFactory * * @package AmeliaBooking\Domain\Factory\Settings */ class SettingsFactory { /** * @param Json $entityJsonData * @param array $globalSettings * * @return Settings */ public static function create($entityJsonData, $globalSettings) { $entitySettings = new Settings(); $generalSettings = new GeneralSettings(); $zoomSettings = new ZoomSettings(); $paymentSettings = new PaymentSettings(); $lessonSpaceSetings = new LessonSpaceSettings(); $data = $entityJsonData ? json_decode($entityJsonData->getValue(), true) : []; $isOldEntitySettings = !isset($data['activation']['version']); if (isset($data['general']['defaultAppointmentStatus'])) { $generalSettings->setDefaultAppointmentStatus($data['general']['defaultAppointmentStatus']); } else { $generalSettings->setDefaultAppointmentStatus($globalSettings['general']['defaultAppointmentStatus']); } if (isset($data['general']['minimumTimeRequirementPriorToBooking'])) { $generalSettings->setMinimumTimeRequirementPriorToBooking( $data['general']['minimumTimeRequirementPriorToBooking'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToBooking( $globalSettings['general']['minimumTimeRequirementPriorToBooking'] ); } if (isset($data['general']['minimumTimeRequirementPriorToCanceling'])) { $generalSettings->setMinimumTimeRequirementPriorToCanceling( $data['general']['minimumTimeRequirementPriorToCanceling'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToCanceling( $globalSettings['general']['minimumTimeRequirementPriorToCanceling'] ); } if (isset($data['general']['minimumTimeRequirementPriorToRescheduling'])) { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $data['general']['minimumTimeRequirementPriorToRescheduling'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $globalSettings['general']['minimumTimeRequirementPriorToRescheduling'] ); } if ($isOldEntitySettings && !isset($globalSettings['general']['minimumTimeRequirementPriorToCanceling'])) { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $generalSettings->getMinimumTimeRequirementPriorToCanceling() ); } if (!empty($data['general']['numberOfDaysAvailableForBooking'])) { $generalSettings->setNumberOfDaysAvailableForBooking( $data['general']['numberOfDaysAvailableForBooking'] ); } else { $generalSettings->setNumberOfDaysAvailableForBooking( $globalSettings['general']['numberOfDaysAvailableForBooking'] ); } if (isset($data['zoom']['enabled'])) { $zoomSettings->setEnabled($data['zoom']['enabled']); } else { $zoomSettings->setEnabled($globalSettings['zoom']['enabled']); } if (isset($data['lessonSpace']['enabled'])) { $lessonSpaceSetings->setEnabled($data['lessonSpace']['enabled']); } else { $lessonSpaceSetings->setEnabled($globalSettings['lessonSpace']['enabled']); } $entitySettings->setGeneralSettings($generalSettings); $entitySettings->setZoomSettings($zoomSettings); $entitySettings->setLessonSpaceSettings($lessonSpaceSetings); return $entitySettings; } } Factory/Cache/CacheFactory.php 0000666 00000002113 15165375612 0012236 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Cache; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Cache\Cache; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class CacheFactory * * @package AmeliaBooking\Domain\Factory\Cache */ class CacheFactory { /** * @param $data * * @return Cache * @throws InvalidArgumentException */ public static function create($data) { $cache = new Cache( new Name($data['name']) ); if (isset($data['id'])) { $cache->setId(new Id($data['id'])); } if (!empty($data['paymentId'])) { $cache->setPaymentId(new Id($data['paymentId'])); } if (!empty($data['data'])) { $cache->setData(new Json($data['data'])); } return $cache; } } Factory/Bookable/Service/PackageCustomerFactory.php 0000666 00000006030 15165375612 0016425 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomer; use AmeliaBooking\Domain\Factory\Payment\PaymentFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; /** * Class PackageCustomerFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageCustomerFactory { /** * @param $data * * @return PackageCustomer * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageCustomer $packageCustomer */ $packageCustomer = new PackageCustomer(); if (isset($data['id'])) { $packageCustomer->setId(new Id($data['id'])); } if (isset($data['packageId'])) { $packageCustomer->setPackageId(new Id($data['packageId'])); } if (isset($data['customerId'])) { $packageCustomer->setCustomerId(new Id($data['customerId'])); } if (isset($data['price'])) { $packageCustomer->setPrice(new Price($data['price'])); } $payments = new Collection(); if (!empty($data['payments'])) { /** @var array $paymentsList */ $paymentsList = $data['payments']; foreach ($paymentsList as $paymentKey => $payment) { $payments->addItem(PaymentFactory::create($payment), $paymentKey); } } $packageCustomer->setPayments($payments); if (!empty($data['end'])) { $packageCustomer->setEnd( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['end'])) ); } if (!empty($data['start'])) { $packageCustomer->setStart( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['start'])) ); } if (!empty($data['purchased'])) { $packageCustomer->setPurchased( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['purchased'])) ); } if (!empty($data['status'])) { $packageCustomer->setStatus( new BookingStatus($data['status']) ); } if (isset($data['bookingsCount'])) { $packageCustomer->setBookingsCount(new WholeNumber($data['bookingsCount'])); } if (isset($data['couponId'])) { $packageCustomer->setCouponId(new Id($data['couponId'])); } return $packageCustomer; } } Factory/Bookable/Service/CategoryFactory.php 0000666 00000003037 15165375612 0015131 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\Service\Category; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class CategoryFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class CategoryFactory { /** * @param array $data * * @return Category * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $category = new Category( new Status($data['status']), new Name($data['name']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $category->setId(new Id($data['id'])); } if (isset($data['serviceList'])) { $services = []; /** @var array $serviceList */ $serviceList = $data['serviceList']; foreach ($serviceList as $service) { $services[] = ServiceFactory::create($service); } $category->setServiceList(new Collection($services)); } if (isset($data['translations'])) { $category->setTranslations(new Json($data['translations'])); } return $category; } } Factory/Bookable/Service/ExtraFactory.php 0000666 00000003416 15165375612 0014440 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Extra; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class ExtraFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ExtraFactory { /** * @param array $data * * @return Extra * @throws InvalidArgumentException */ public static function create($data) { $extra = new Extra( new Name($data['name']), new Description($data['description']), new Price($data['price']), new PositiveInteger($data['maxQuantity']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $extra->setId(new Id($data['id'])); } if (!empty($data['duration'])) { $extra->setDuration(new Duration($data['duration'])); } if (isset($data['serviceId'])) { $extra->setServiceId(new Id($data['serviceId'])); } if (isset($data['aggregatedPrice'])) { $extra->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['translations'])) { $extra->setTranslations(new Json($data['translations'])); } return $extra; } } Factory/Bookable/Service/ServiceFactory.php 0000666 00000032204 15165375612 0014752 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Cycle; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Priority; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class ServiceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ServiceFactory { /** * @param $data * * @return Service * @throws InvalidArgumentException */ public static function create($data) { $service = new Service(); if (isset($data['id'])) { $service->setId(new Id($data['id'])); } if (isset($data['name'])) { $service->setName(new Name($data['name'])); } if (isset($data['price'])) { $service->setPrice(new Price($data['price'])); } if (isset($data['status'])) { $service->setStatus(new Status($data['status'])); } if (isset($data['categoryId'])) { $service->setCategoryId(new Id($data['categoryId'])); } if (isset($data['minCapacity'])) { $service->setMinCapacity(new IntegerValue($data['minCapacity'])); } if (isset($data['maxCapacity'])) { $service->setMaxCapacity(new IntegerValue($data['maxCapacity'])); } if (isset($data['duration'])) { $service->setDuration(new PositiveDuration($data['duration'])); } if (isset($data['description'])) { $service->setDescription(new Description($data['description'])); } if (isset($data['color'])) { $service->setColor(new Color($data['color'])); } if (!empty($data['timeBefore'])) { $service->setTimeBefore(new Duration($data['timeBefore'])); } if (!empty($data['timeAfter'])) { $service->setTimeAfter(new Duration($data['timeAfter'])); } if (isset($data['bringingAnyone'])) { $service->setBringingAnyone(new BooleanValueObject($data['bringingAnyone'])); } if (isset($data['aggregatedPrice'])) { $service->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (!empty($data['priority'])) { $service->setPriority(new Priority($data['priority'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $service->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['position'])) { $service->setPosition(new PositiveInteger($data['position'])); } if (isset($data['show'])) { $service->setShow(new BooleanValueObject($data['show'])); } if (!empty($data['settings'])) { $service->setSettings(new Json($data['settings'])); } if (!empty($data['recurringCycle'])) { $service->setRecurringCycle(new Cycle($data['recurringCycle'])); } if (!empty($data['recurringSub'])) { $service->setRecurringSub(new Name($data['recurringSub'])); } if (isset($data['recurringPayment'])) { $service->setRecurringPayment(new WholeNumber($data['recurringPayment'])); } if (isset($data['translations'])) { $service->setTranslations(new Json($data['translations'])); } if (!empty($data['customPricing'])) { $service->setCustomPricing(new Json($data['customPricing'])); } if (isset($data['limitPerCustomer'])) { $service->setLimitPerCustomer(new Json($data['limitPerCustomer'])); } if (isset($data['deposit'])) { $service->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $service->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['depositPerPerson'])) { $service->setDepositPerPerson(new BooleanValueObject($data['depositPerPerson'])); } if (isset($data['mandatoryExtra'])) { $service->setMandatoryExtra(new BooleanValueObject($data['mandatoryExtra'])); } if (!empty($data['minSelectedExtras'])) { $service->setMinSelectedExtras(new IntegerValue($data['minSelectedExtras'])); } if (isset($data['fullPayment'])) { $service->setFullPayment(new BooleanValueObject($data['fullPayment'])); } $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::SERVICE), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($service->getId()) { $galleryImage->setEntityId($service->getId()); } $gallery->addItem($galleryImage); } } $service->setGallery($gallery); $extras = new Collection(); if (!empty($data['extras'])) { /** @var array $extrasList */ $extrasList = $data['extras']; foreach ($extrasList as $extraKey => $extra) { $extras->addItem(ExtraFactory::create($extra), $extraKey); } } $service->setExtras($extras); $coupons = new Collection(); if (!empty($data['coupons'])) { /** @var array $couponsList */ $couponsList = $data['coupons']; foreach ($couponsList as $couponKey => $coupon) { $coupons->addItem(CouponFactory::create($coupon), $couponKey); } } $service->setCoupons($coupons); if (isset($data['maxExtraPeople'])) { $service->setMaxExtraPeople(new IntegerValue($data['maxExtraPeople'])); } return $service; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $services = []; foreach ($rows as $row) { $serviceId = $row['service_id']; $extraId = $row['extra_id']; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $services[$serviceId]['id'] = $row['service_id']; $services[$serviceId]['name'] = $row['service_name']; $services[$serviceId]['description'] = $row['service_description']; $services[$serviceId]['color'] = $row['service_color']; $services[$serviceId]['price'] = $row['service_price']; $services[$serviceId]['status'] = $row['service_status']; $services[$serviceId]['categoryId'] = $row['service_categoryId']; $services[$serviceId]['minCapacity'] = $row['service_minCapacity']; $services[$serviceId]['maxCapacity'] = $row['service_maxCapacity']; $services[$serviceId]['maxExtraPeople'] = isset($row['service_maxExtraPeople']) ? $row['service_maxExtraPeople'] : null; $services[$serviceId]['duration'] = $row['service_duration']; $services[$serviceId]['timeAfter'] = $row['service_timeAfter']; $services[$serviceId]['timeBefore'] = $row['service_timeBefore']; $services[$serviceId]['bringingAnyone'] = $row['service_bringingAnyone']; $services[$serviceId]['pictureFullPath'] = $row['service_picture_full']; $services[$serviceId]['pictureThumbPath'] = $row['service_picture_thumb']; $services[$serviceId]['position'] = isset($row['service_position']) ? $row['service_position'] : 0; $services[$serviceId]['show'] = isset($row['service_show']) ? $row['service_show'] : 0; $services[$serviceId]['aggregatedPrice'] = isset($row['service_aggregatedPrice']) ? $row['service_aggregatedPrice'] : 0; $services[$serviceId]['settings'] = isset($row['service_settings']) ? $row['service_settings'] : null; $services[$serviceId]['recurringCycle'] = isset($row['service_recurringCycle']) ? $row['service_recurringCycle'] : null; $services[$serviceId]['recurringSub'] = isset($row['service_recurringSub']) ? $row['service_recurringSub'] : null; $services[$serviceId]['recurringPayment'] = isset($row['service_recurringPayment']) ? $row['service_recurringPayment'] : null; $services[$serviceId]['translations'] = isset($row['service_translations']) ? $row['service_translations'] : null; $services[$serviceId]['customPricing'] = isset($row['service_customPricing']) ? $row['service_customPricing'] : null; $services[$serviceId]['limitPerCustomer'] = isset($row['service_limitPerCustomer']) ? $row['service_limitPerCustomer'] : null; $services[$serviceId]['deposit'] = isset($row['service_deposit']) ? $row['service_deposit'] : null; $services[$serviceId]['depositPayment'] = isset($row['service_depositPayment']) ? $row['service_depositPayment'] : null; $services[$serviceId]['depositPerPerson'] = isset($row['service_depositPerPerson']) ? $row['service_depositPerPerson'] : null; $services[$serviceId]['mandatoryExtra'] = isset($row['service_mandatoryExtra']) ? $row['service_mandatoryExtra'] : null; $services[$serviceId]['minSelectedExtras'] = isset($row['service_minSelectedExtras']) ? $row['service_minSelectedExtras'] : null; $services[$serviceId]['fullPayment'] = isset($row['service_fullPayment']) ? $row['service_fullPayment'] : null; if ($extraId) { $services[$serviceId]['extras'][$extraId]['id'] = $row['extra_id']; $services[$serviceId]['extras'][$extraId]['name'] = $row['extra_name']; $services[$serviceId]['extras'][$extraId]['description'] = isset($row['extra_description']) ? $row['extra_description'] : null; $services[$serviceId]['extras'][$extraId]['price'] = $row['extra_price']; $services[$serviceId]['extras'][$extraId]['maxQuantity'] = $row['extra_maxQuantity']; $services[$serviceId]['extras'][$extraId]['duration'] = $row['extra_duration']; $services[$serviceId]['extras'][$extraId]['position'] = $row['extra_position']; $services[$serviceId]['extras'][$extraId]['aggregatedPrice'] = $row['extra_aggregatedPrice']; $services[$serviceId]['extras'][$extraId]['translations'] = $row['extra_translations']; } if ($galleryId) { $services[$serviceId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $services[$serviceId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $services[$serviceId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $services[$serviceId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } } $servicesCollection = new Collection(); foreach ($services as $serviceKey => $serviceArray) { if (!array_key_exists('extras', $serviceArray)) { $serviceArray['extras'] = []; } if (!array_key_exists('gallery', $serviceArray)) { $serviceArray['gallery'] = []; } $servicesCollection->addItem( self::create($serviceArray), $serviceKey ); } return $servicesCollection; } } Factory/Bookable/Service/PackageCustomerServiceFactory.php 0000666 00000012261 15165375612 0017751 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomer; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomerService; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageCustomerFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageCustomerServiceFactory { /** * @param $data * * @return PackageCustomerService * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageCustomerService $packageCustomerService */ $packageCustomerService = new PackageCustomerService(); if (isset($data['id'])) { $packageCustomerService->setId(new Id($data['id'])); } if (isset($data['packageCustomer'])) { /** @var PackageCustomer $packageCustomer */ $packageCustomer = PackageCustomerFactory::create($data['packageCustomer']); $packageCustomerService->setPackageCustomer($packageCustomer); } if (isset($data['serviceId'])) { $packageCustomerService->setServiceId(new Id($data['serviceId'])); } if (isset($data['providerId'])) { $packageCustomerService->setProviderId(new Id($data['providerId'])); } if (isset($data['locationId'])) { $packageCustomerService->setLocationId(new Id($data['locationId'])); } if (isset($data['bookingsCount'])) { $packageCustomerService->setBookingsCount(new WholeNumber($data['bookingsCount'])); } return $packageCustomerService; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $packagesCustomersServices = []; foreach ($rows as $row) { $packageCustomerServiceId = $row['package_customer_service_id']; if (!array_key_exists($packageCustomerServiceId, $packagesCustomersServices)) { $packagesCustomersServices[$packageCustomerServiceId] = [ 'id' => $packageCustomerServiceId, 'serviceId' => $row['package_customer_service_serviceId'], 'providerId' => $row['package_customer_service_providerId'], 'locationId' => $row['package_customer_service_locationId'], 'bookingsCount' => $row['package_customer_service_bookingsCount'], 'packageCustomer' => [ 'id' => $row['package_customer_id'], 'customerId' => $row['package_customer_customerId'], 'packageId' => $row['package_customer_packageId'], 'price' => $row['package_customer_price'], 'start' => $row['package_customer_start'], 'end' => $row['package_customer_end'], 'purchased' => DateTimeService::getCustomDateTimeFromUtc( $row['package_customer_purchased'] ), 'status' => $row['package_customer_status'], 'bookingsCount' => $row['package_customer_bookingsCount'], 'couponId' => $row['package_customer_couponId'], ] ]; } if (!empty($row['payment_id'])) { $packagesCustomersServices[$packageCustomerServiceId]['packageCustomer']['payments'][$row['payment_id']] = [ 'id' => $row['payment_id'], 'customerBookingId' => null, 'packageCustomerId' => $row['payment_packageCustomerId'], 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null ]; } } /** @var Collection $collection */ $collection = new Collection(); foreach ($packagesCustomersServices as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Factory/Bookable/Service/ResourceFactory.php 0000666 00000007170 15165375612 0015145 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Resource; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class ResourceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ResourceFactory { /** * @param $data * * @return Resource * @throws InvalidArgumentException */ public static function create($data) { /** @var Resource $resource */ $resource = new Resource(); if (isset($data['id'])) { $resource->setId(new Id($data['id'])); } if (isset($data['name'])) { $resource->setName(new Name($data['name'])); } if (!empty($data['quantity'])) { $resource->setQuantity(new PositiveInteger($data['quantity'])); } if (!empty($data['status'])) { $resource->setStatus(new Status($data['status'])); } if (isset($data['shared'])) { $resource->setShared(new EntityType($data['shared'])); } if (isset($data['entities'])) { $resource->setEntities(($data['entities'])); } if (!empty($data['countAdditionalPeople'])) { $resource->setCountAdditionalPeople(new BooleanValueObject($data['countAdditionalPeople'])); } return $resource; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $resources = []; foreach ($rows as $row) { $resourceId = $row['resource_id']; $resourceEntityId = $row['resource_entity_id']; $resources[$resourceId]['id'] = $row['resource_id']; $resources[$resourceId]['name'] = $row['resource_name']; $resources[$resourceId]['quantity'] = $row['resource_quantity']; $resources[$resourceId]['countAdditionalPeople'] = $row['resource_countAdditionalPeople']; $resources[$resourceId]['status'] = $row['resource_status']; $resources[$resourceId]['shared'] = $row['resource_shared']; if (!isset($resources[$resourceId]['entities'])) { $resources[$resourceId]['entities'] = []; } if ($resourceEntityId) { $resources[$resourceId]['entities'][$resourceEntityId]['id'] = (int)$resourceEntityId; $resources[$resourceId]['entities'][$resourceEntityId]['resourceId'] = (int)$resourceId; $resources[$resourceId]['entities'][$resourceEntityId]['entityId'] = (int)$row['resource_entity_entityId']; $resources[$resourceId]['entities'][$resourceEntityId]['entityType'] = $row['resource_entity_entityType']; } } $resourcesCollection = new Collection(); foreach ($resources as $key => $resourceArray) { $resourcesCollection->addItem( self::create($resourceArray), $key ); } return $resourcesCollection; } } Factory/Bookable/Service/PackageServiceFactory.php 0000666 00000005002 15165375612 0016222 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageService; use AmeliaBooking\Domain\Factory\Location\LocationFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageServiceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageServiceFactory { /** * @param $data * * @return PackageService * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageService $packageService */ $packageService = new PackageService(); if (isset($data['id'])) { $packageService->setId(new Id($data['id'])); } if (isset($data['quantity'])) { $packageService->setQuantity(new PositiveInteger($data['quantity'])); } if (isset($data['service'])) { $packageService->setService(ServiceFactory::create($data['service'])); } if (isset($data['minimumScheduled'])) { $packageService->setMinimumScheduled(new WholeNumber($data['minimumScheduled'])); } if (isset($data['maximumScheduled'])) { $packageService->setMaximumScheduled(new WholeNumber($data['maximumScheduled'])); } if (isset($data['allowProviderSelection'])) { $packageService->setAllowProviderSelection(new BooleanValueObject($data['allowProviderSelection'])); } $packageService->setProviders(new Collection()); if (!empty($data['providers'])) { foreach ($data['providers'] as $providerData) { $packageService->getProviders()->addItem(UserFactory::create($providerData)); } } $packageService->setLocations(new Collection()); if (!empty($data['locations'])) { foreach ($data['locations'] as $locationData) { $packageService->getLocations()->addItem(LocationFactory::create($locationData)); } } return $packageService; } } Factory/Bookable/Service/PackageFactory.php 0000666 00000032036 15165375612 0014710 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Package; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class PackageFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageFactory { /** * @param $data * * @return Package * @throws InvalidArgumentException */ public static function create($data) { /** @var Package $package */ $package = new Package(); if (isset($data['id'])) { $package->setId(new Id($data['id'])); } if (isset($data['name'])) { $package->setName(new Name($data['name'])); } if (isset($data['price'])) { $package->setPrice(new Price($data['price'])); } if (isset($data['description'])) { $package->setDescription(new Description($data['description'])); } if (isset($data['color'])) { $package->setColor(new Color($data['color'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $package->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['position'])) { $package->setPosition(new PositiveInteger($data['position'])); } if (!empty($data['status'])) { $package->setStatus(new Status($data['status'])); } if (isset($data['calculatedPrice'])) { $package->setCalculatedPrice(new BooleanValueObject($data['calculatedPrice'])); } if (isset($data['discount'])) { $package->setDiscount(new DiscountPercentageValue($data['discount'])); } if (!empty($data['settings'])) { $package->setSettings(new Json($data['settings'])); } if (!empty($data['endDate'])) { $package->setEndDate( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])) ); } if (!empty($data['durationCount'])) { $package->setDurationCount(new PositiveInteger($data['durationCount'])); } if (!empty($data['durationType'])) { $package->setDurationType(new Label($data['durationType'])); } if (isset($data['deposit'])) { $package->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $package->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['fullPayment'])) { $package->setFullPayment(new BooleanValueObject($data['fullPayment'])); } if (isset($data['limitPerCustomer'])) { $package->setLimitPerCustomer(new Json($data['limitPerCustomer'])); } /** @var Collection $gallery */ $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::PACKAGE), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($package->getId()) { $galleryImage->setEntityId($package->getId()); } $gallery->addItem($galleryImage); } } $package->setGallery($gallery); if (!empty($data['translations'])) { $package->setTranslations(new Json($data['translations'])); } if (isset($data['sharedCapacity'])) { $package->setSharedCapacity(new BooleanValueObject($data['sharedCapacity'])); } if (isset($data['quantity'])) { $package->setQuantity(new PositiveInteger($data['quantity'])); } /** @var Collection $bookable */ $bookable = new Collection(); if (!empty($data['bookable'])) { foreach ($data['bookable'] as $key => $value) { $bookable->addItem(PackageServiceFactory::create($value), $key); } } $package->setBookable($bookable); return $package; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $packages = []; foreach ($rows as $row) { $packageId = $row['package_id']; $bookableId = $row['package_service_id']; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $locationId = isset($row['location_id']) ? $row['location_id'] : null; $packages[$packageId]['id'] = $row['package_id']; $packages[$packageId]['name'] = $row['package_name']; $packages[$packageId]['description'] = $row['package_description']; $packages[$packageId]['color'] = $row['package_color']; $packages[$packageId]['price'] = $row['package_price']; $packages[$packageId]['status'] = $row['package_status']; $packages[$packageId]['pictureFullPath'] = $row['package_picture_full']; $packages[$packageId]['pictureThumbPath'] = $row['package_picture_thumb']; $packages[$packageId]['position'] = isset($row['package_position']) ? $row['package_position'] : 0; $packages[$packageId]['calculatedPrice'] = $row['package_calculated_price']; $packages[$packageId]['sharedCapacity'] = isset($row['package_sharedCapacity']) ? $row['package_sharedCapacity'] : null; $packages[$packageId]['quantity'] = isset($row['package_quantity']) ? $row['package_quantity'] : null; $packages[$packageId]['discount'] = $row['package_discount']; $packages[$packageId]['settings'] = $row['package_settings']; $packages[$packageId]['endDate'] = $row['package_endDate']; $packages[$packageId]['durationCount'] = $row['package_durationCount']; $packages[$packageId]['durationType'] = $row['package_durationType']; $packages[$packageId]['translations'] = $row['package_translations']; $packages[$packageId]['deposit'] = isset($row['package_deposit']) ? $row['package_deposit'] : null; $packages[$packageId]['depositPayment'] = isset($row['package_depositPayment']) ? $row['package_depositPayment'] : null; $packages[$packageId]['fullPayment'] = isset($row['package_fullPayment']) ? $row['package_fullPayment'] : 0; $packages[$packageId]['limitPerCustomer'] = isset($row['package_limitPerCustomer']) ? $row['package_limitPerCustomer'] : null; if ($bookableId) { $packages[$packageId]['bookable'][$bookableId]['id'] = $bookableId; $packages[$packageId]['bookable'][$bookableId]['service']['id'] = $row['service_id']; $packages[$packageId]['bookable'][$bookableId]['service']['name'] = $row['service_name']; $packages[$packageId]['bookable'][$bookableId]['service']['description'] = !empty($row['service_description']) ? $row['service_description'] : null; $packages[$packageId]['bookable'][$bookableId]['service']['status'] = $row['service_status']; $packages[$packageId]['bookable'][$bookableId]['service']['categoryId'] = $row['service_categoryId']; $packages[$packageId]['bookable'][$bookableId]['service']['duration'] = $row['service_duration']; $packages[$packageId]['bookable'][$bookableId]['service']['timeBefore'] = $row['service_timeBefore']; $packages[$packageId]['bookable'][$bookableId]['service']['timeAfter'] = $row['service_timeAfter']; $packages[$packageId]['bookable'][$bookableId]['service']['price'] = $row['service_price']; $packages[$packageId]['bookable'][$bookableId]['service']['minCapacity'] = $row['service_minCapacity']; $packages[$packageId]['bookable'][$bookableId]['service']['maxCapacity'] = $row['service_maxCapacity']; $packages[$packageId]['bookable'][$bookableId]['service']['pictureFullPath'] = $row['service_picture_full']; $packages[$packageId]['bookable'][$bookableId]['service']['pictureThumbPath'] = $row['service_picture_thumb']; $packages[$packageId]['bookable'][$bookableId]['service']['translations'] = !empty($row['service_translations']) ? $row['service_translations'] : null; $packages[$packageId]['bookable'][$bookableId]['quantity'] = $row['package_service_quantity']; $packages[$packageId]['bookable'][$bookableId]['minimumScheduled'] = $row['package_service_minimumScheduled']; $packages[$packageId]['bookable'][$bookableId]['maximumScheduled'] = $row['package_service_maximumScheduled']; $packages[$packageId]['bookable'][$bookableId]['allowProviderSelection'] = $row['package_service_allowProviderSelection']; $packages[$packageId]['bookable'][$bookableId]['service']['show'] = !empty($row['service_show']) ? $row['service_show'] : null; } if ($galleryId) { $packages[$packageId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $packages[$packageId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $packages[$packageId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $packages[$packageId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } if ($providerId) { $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['id'] = $row['provider_id']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['firstName'] = $row['provider_firstName']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['lastName'] = $row['provider_lastName']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['email'] = $row['provider_email']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['status'] = !empty($row['provider_status']) ? $row['provider_status'] : Status::VISIBLE; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['type'] = Entities::PROVIDER; } if ($locationId) { $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['id'] = $row['location_id']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['name'] = $row['location_name']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['address'] = $row['location_address']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['phone'] = $row['location_phone']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['latitude'] = $row['location_latitude']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['longitude'] = $row['location_longitude']; } } $packagesCollection = new Collection(); foreach ($packages as $packageKey => $packageArray) { if (!array_key_exists('gallery', $packageArray)) { $packageArray['gallery'] = []; } $packagesCollection->addItem( self::create($packageArray), $packageKey ); } return $packagesCollection; } } Factory/Outlook/OutlookCalendarFactory.php 0000666 00000001666 15165375612 0014766 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Outlook; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Outlook\OutlookCalendar; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class OutlookCalendarFactory * * @package AmeliaBooking\Domain\Factory\Outlook */ class OutlookCalendarFactory { /** * @param $data * * @return OutlookCalendar * @throws InvalidArgumentException */ public static function create($data) { $outlookCalendar = new OutlookCalendar( new Token($data['token']), new Label(empty($data['calendarId']) ? null : $data['calendarId']) ); if (isset($data['id'])) { $outlookCalendar->setId(new Id($data['id'])); } return $outlookCalendar; } } Factory/Gallery/GalleryImageFactory.php 0000666 00000002436 15165375612 0014201 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Gallery; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\EntityType; /** * Class GalleryImageFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class GalleryImageFactory { /** * @param $data * * @return GalleryImage * @throws InvalidArgumentException */ public static function create($data) { $galleryImage = new GalleryImage( new EntityType($data['entityType']), new Picture($data['pictureFullPath'], $data['pictureThumbPath']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $galleryImage->setId(new Id($data['id'])); } if (isset($data['entityId'])) { $galleryImage->setEntityId(new Id($data['entityId'])); } if (isset($data['entityType'])) { $galleryImage->setEntityType(new EntityType($data['entityType'])); } return $galleryImage; } } Factory/CustomField/CustomFieldFactory.php 0000666 00000015064 15165375612 0014675 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\CustomField; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\CustomField\CustomField; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\EventFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\CustomFieldType; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomFieldFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class CustomFieldFactory { /** * @param $data * * @return CustomField * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $customField = new CustomField( new Label($data['label']), new CustomFieldType($data['type']), new BooleanValueObject($data['required']), new IntegerValue($data['position']) ); if (isset($data['id'])) { $customField->setId(new Id($data['id'])); } if (isset($data['options'])) { $optionList = []; /** @var array $options */ $options = $data['options']; foreach ($options as $option) { $optionList[] = CustomFieldOptionFactory::create($option); } $customField->setOptions(new Collection($optionList)); } if (isset($data['translations'])) { $customField->setTranslations(new Json($data['translations'])); } $serviceList = []; if (isset($data['allServices']) && $data['allServices']) { $customField->setAllServices(new BooleanValueObject(true)); } else { $customField->setAllServices(new BooleanValueObject(false)); if (isset($data['services'])) { /** @var array $options */ $services = $data['services']; foreach ($services as $service) { $serviceList[] = ServiceFactory::create($service); } } } $customField->setServices(new Collection($serviceList)); $eventList = []; if (isset($data['allEvents']) && $data['allEvents']) { $customField->setAllEvents(new BooleanValueObject(true)); } else { $customField->setAllEvents(new BooleanValueObject(false)); if (isset($data['events'])) { /** @var array $options */ $events = $data['events']; foreach ($events as $event) { $eventList[] = EventFactory::create($event); } } } $customField->setEvents(new Collection($eventList)); return $customField; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($rows) { $customFields = []; foreach ($rows as $row) { $customFieldId = $row['cf_id']; $optionId = $row['cfo_id']; $serviceId = $row['s_id']; $eventId = $row['e_id']; $customFields[$customFieldId]['id'] = $row['cf_id']; $customFields[$customFieldId]['label'] = $row['cf_label']; $customFields[$customFieldId]['type'] = $row['cf_type']; $customFields[$customFieldId]['required'] = $row['cf_required']; $customFields[$customFieldId]['position'] = $row['cf_position']; $customFields[$customFieldId]['translations'] = $row['cf_translations']; $customFields[$customFieldId]['allServices'] = $row['cf_allServices']; $customFields[$customFieldId]['allEvents'] = $row['cf_allEvents']; if ($optionId) { $customFields[$customFieldId]['options'][$optionId]['id'] = $row['cfo_id']; $customFields[$customFieldId]['options'][$optionId]['customFieldId'] = $row['cfo_custom_field_id']; $customFields[$customFieldId]['options'][$optionId]['label'] = $row['cfo_label']; $customFields[$customFieldId]['options'][$optionId]['position'] = $row['cfo_position']; $customFields[$customFieldId]['options'][$optionId]['translations'] = $row['cfo_translations']; } if ($serviceId) { $customFields[$customFieldId]['services'][$serviceId]['id'] = $row['s_id']; $customFields[$customFieldId]['services'][$serviceId]['name'] = $row['s_name']; $customFields[$customFieldId]['services'][$serviceId]['description'] = $row['s_description']; $customFields[$customFieldId]['services'][$serviceId]['color'] = $row['s_color']; $customFields[$customFieldId]['services'][$serviceId]['price'] = $row['s_price']; $customFields[$customFieldId]['services'][$serviceId]['status'] = $row['s_status']; $customFields[$customFieldId]['services'][$serviceId]['categoryId'] = $row['s_categoryId']; $customFields[$customFieldId]['services'][$serviceId]['minCapacity'] = $row['s_minCapacity']; $customFields[$customFieldId]['services'][$serviceId]['maxCapacity'] = $row['s_maxCapacity']; $customFields[$customFieldId]['services'][$serviceId]['duration'] = $row['s_duration']; } if ($eventId) { $customFields[$customFieldId]['events'][$eventId]['id'] = $row['e_id']; $customFields[$customFieldId]['events'][$eventId]['name'] = $row['e_name']; $customFields[$customFieldId]['events'][$eventId]['price'] = $row['e_price']; $customFields[$customFieldId]['events'][$eventId]['parentId'] = $row['e_parentId']; } } $customFieldsCollection = new Collection(); foreach ($customFields as $customFieldKey => $customFieldArray) { if (!array_key_exists('options', $customFieldArray)) { $customFieldArray['options'] = []; } $customFieldsCollection->addItem( self::create($customFieldArray), $customFieldKey ); } return $customFieldsCollection; } } Factory/CustomField/CustomFieldOptionFactory.php 0000666 00000002243 15165375612 0016061 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\CustomField; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\CustomField\CustomFieldOption; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomFieldOptionFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class CustomFieldOptionFactory { /** * @param $data * * @return CustomFieldOption * @throws InvalidArgumentException */ public static function create($data) { $customFieldOption = new CustomFieldOption( new Id($data['customFieldId']), new Label($data['label']), new IntegerValue($data['position']) ); if (isset($data['translations'])) { $customFieldOption->setTranslations(new Json($data['translations'])); } if (isset($data['id'])) { $customFieldOption->setId(new Id($data['id'])); } return $customFieldOption; } } Factory/Coupon/CouponFactory.php 0000666 00000016277 15165375612 0012756 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Coupon; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Coupon\Coupon; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\EventFactory; use AmeliaBooking\Domain\Factory\Bookable\Service\PackageFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountFixedValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\CouponCode; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class CouponFactory * * @package AmeliaBooking\Domain\Factory\Coupon */ class CouponFactory { /** * @param $data * * @return Coupon * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $coupon = new Coupon( new CouponCode($data['code']), new DiscountPercentageValue($data['discount']), new DiscountFixedValue($data['deduction']), new PositiveInteger((int)$data['limit']), new Status($data['status']) ); if (isset($data['id'])) { $coupon->setId(new Id($data['id'])); } $serviceList = new Collection(); if (isset($data['serviceList'])) { foreach ((array)$data['serviceList'] as $key => $value) { $serviceList->addItem( ServiceFactory::create($value), $key ); } } $eventList = new Collection(); if (isset($data['eventList'])) { foreach ((array)$data['eventList'] as $key => $value) { $eventList->addItem( EventFactory::create($value), $key ); } } $packageList = new Collection(); if (isset($data['packageList'])) { foreach ((array)$data['packageList'] as $key => $value) { $packageList->addItem( PackageFactory::create($value), $key ); } } if (isset($data['customerLimit'])) { $coupon->setCustomerLimit(new WholeNumber((int)$data['customerLimit'])); } if (isset($data['notificationInterval'])) { $coupon->setNotificationInterval(new WholeNumber($data['notificationInterval'])); } if (isset($data['notificationRecurring'])) { $coupon->setNotificationRecurring(new BooleanValueObject($data['notificationRecurring'])); } if (isset($data['used'])) { $coupon->setUsed(new WholeNumber($data['used'])); } if (!empty($data['expirationDate'])) { if (is_string($data['expirationDate'])) { $coupon->setExpirationDate(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['expirationDate']))); } else { $coupon->setExpirationDate(new DateTimeValue($data['expirationDate'])); } } $coupon->setServiceList($serviceList); $coupon->setEventList($eventList); $coupon->setPackageList($packageList); return $coupon; } /** * @param array $rows * * @return Collection * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($rows) { $coupons = []; foreach ($rows as $row) { $couponId = $row['coupon_id']; $serviceId = isset($row['service_id']) ? $row['service_id'] : null; $eventId = isset($row['event_id']) ? $row['event_id'] : null; $packageId = isset($row['package_id']) ? $row['package_id'] : null; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $coupons[$couponId]['id'] = $couponId; $coupons[$couponId]['code'] = $row['coupon_code']; $coupons[$couponId]['discount'] = $row['coupon_discount']; $coupons[$couponId]['deduction'] = $row['coupon_deduction']; $coupons[$couponId]['limit'] = $row['coupon_limit']; $coupons[$couponId]['customerLimit'] = $row['coupon_customerLimit']; $coupons[$couponId]['notificationInterval'] = $row['coupon_notificationInterval']; $coupons[$couponId]['notificationRecurring'] = $row['coupon_notificationRecurring']; $coupons[$couponId]['status'] = $row['coupon_status']; $coupons[$couponId]['expirationDate'] = $row['coupon_expirationDate']; if ($bookingId) { $coupons[$couponId]['bookings'][$bookingId] = $bookingId; } if ($serviceId) { $coupons[$couponId]['serviceList'][$serviceId]['id'] = $serviceId; $coupons[$couponId]['serviceList'][$serviceId]['name'] = $row['service_name']; $coupons[$couponId]['serviceList'][$serviceId]['description'] = $row['service_description']; $coupons[$couponId]['serviceList'][$serviceId]['color'] = $row['service_color']; $coupons[$couponId]['serviceList'][$serviceId]['status'] = $row['service_status']; $coupons[$couponId]['serviceList'][$serviceId]['categoryId'] = $row['service_categoryId']; $coupons[$couponId]['serviceList'][$serviceId]['duration'] = $row['service_duration']; $coupons[$couponId]['serviceList'][$serviceId]['price'] = $row['service_price']; $coupons[$couponId]['serviceList'][$serviceId]['minCapacity'] = $row['service_minCapacity']; $coupons[$couponId]['serviceList'][$serviceId]['maxCapacity'] = $row['service_maxCapacity']; } if ($eventId) { $coupons[$couponId]['eventList'][$eventId]['id'] = $eventId; $coupons[$couponId]['eventList'][$eventId]['name'] = $row['event_name']; $coupons[$couponId]['eventList'][$eventId]['price'] = $row['event_price']; } if ($packageId) { $coupons[$couponId]['packageList'][$packageId]['id'] = $packageId; $coupons[$couponId]['packageList'][$packageId]['name'] = $row['package_name']; $coupons[$couponId]['packageList'][$packageId]['price'] = $row['package_price']; } } $couponsCollection = new Collection(); foreach ($coupons as $couponKey => $couponArray) { $couponArray['used'] = isset($couponArray['bookings']) ? sizeof($couponArray['bookings']) : 0; $couponsCollection->addItem( self::create($couponArray), $couponKey ); } return $couponsCollection; } } Factory/Location/LocationFactory.php 0000666 00000004351 15165375612 0013556 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Location; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Address; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\GeoTag; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class LocationFactory * * @package AmeliaBooking\Domain\Factory\Location */ class LocationFactory { /** * @param $data * * @return Location * @throws InvalidArgumentException */ public static function create($data) { $location = new Location(); if (isset($data['id'])) { $location->setId(new Id($data['id'])); } if (isset($data['name'])) { $location->setName(new Name($data['name'])); } if (isset($data['address'])) { $location->setAddress(new Address($data['address'])); } if (isset($data['phone'])) { $location->setPhone(new Phone($data['phone'])); } if (isset($data['latitude'], $data['longitude'])) { $location->setCoordinates(new GeoTag($data['latitude'], $data['longitude'])); } if (isset($data['description'])) { $location->setDescription(new Description($data['description'])); } if (isset($data['status'])) { $location->setStatus(new Status($data['status'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $location->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (isset($data['pin'])) { $location->setPin(new Url($data['pin'])); } if (!empty($data['translations'])) { $location->setTranslations(new Json($data['translations'])); } return $location; } } Factory/Location/ProviderLocationFactory.php 0000666 00000001304 15165375612 0015264 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Location; use AmeliaBooking\Domain\Entity\Location\ProviderLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class ProviderLocationFactory * * @package AmeliaBooking\Domain\Factory\Location */ class ProviderLocationFactory { /** * @param $data * * @return ProviderLocation */ public static function create($data) { $providerLocation = new ProviderLocation( new Id($data['userId']), new Id($data['locationId']) ); if (isset($data['id'])) { $providerLocation->setId(new Id($data['id'])); } return $providerLocation; } } Factory/Notification/NotificationFactory.php 0000666 00000005160 15165375612 0015311 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Notification; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Notification\Notification; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\TimeOfDay; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Html; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo; use AmeliaBooking\Domain\ValueObjects\String\NotificationStatus; use AmeliaBooking\Domain\ValueObjects\String\NotificationType; /** * Class NotificationFactory * * @package AmeliaBooking\Domain\Factory\Notification */ class NotificationFactory { /** * @param array $data * * @return Notification * @throws InvalidArgumentException */ public static function create($data) { $notification = new Notification( new Name($data['name']), new NotificationStatus($data['status']), new NotificationType($data['type']), new BookingType($data['entity']), new NotificationSendTo($data['sendTo']), new Name($data['subject']), new Html($data['content']) ); if (isset($data['id'])) { $notification->setId(new Id($data['id'])); } if (isset($data['customName']) && !empty($data['customName'])) { $notification->setCustomName($data['customName']); } if (isset($data['time'])) { $notification->setTime(new TimeOfDay($data['time'])); } if (isset($data['timeBefore'])) { $notification->setTimeBefore(new Duration($data['timeBefore'])); } if (isset($data['translations'])) { $notification->setTranslations(new Json($data['translations'])); } if (isset($data['timeAfter'])) { $notification->setTimeAfter(new Duration($data['timeAfter'])); } if (isset($data['entityIds'])) { $notification->setEntityIds(($data['entityIds'])); } if (isset($data['sendOnlyMe']) && !empty($data['sendOnlyMe'])) { $notification->setSendOnlyMe(new BooleanValueObject($data['sendOnlyMe'])); } if (isset($data['whatsAppTemplate'])) { $notification->setWhatsAppTemplate($data['whatsAppTemplate']); } return $notification; } } Factory/Notification/NotificationLogFactory.php 0000666 00000004156 15165375612 0015757 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Notification; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Notification\NotificationLog; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use Exception; /** * Class NotificationLogFactory * * @package AmeliaBooking\Domain\Factory\Notification */ class NotificationLogFactory { /** * @param array $data * * @return NotificationLog * @throws InvalidArgumentException * @throws Exception */ public static function create($data) { $notificationLog = new NotificationLog(); if (isset($data['id'])) { $notificationLog->setId(new Id($data['id'])); } if (isset($data['notificationId'])) { $notificationLog->setNotificationsId(new Id($data['notificationId'])); } if (isset($data['userId'])) { $notificationLog->setUserId(new Id($data['userId'])); } if (isset($data['appointmentId'])) { $notificationLog->setAppointmentId(new Id($data['appointmentId'])); } if (isset($data['eventId'])) { $notificationLog->setEventId(new Id($data['eventId'])); } if (isset($data['packageCustomerId'])) { $notificationLog->setPackageCustomerId(new Id($data['packageCustomerId'])); } if (isset($data['sentDateTime'])) { $notificationLog->setSentDateTime( new DateTimeValue( DateTimeService::getCustomDateTimeObjectFromUtc($data['sentDateTime']) ) ); } if (isset($data['sent'])) { $notificationLog->setSent(new BooleanValueObject($data['sent'])); } if (isset($data['data'])) { $notificationLog->setData(new Json($data['data'])); } return $notificationLog; } } Factory/Zoom/ZoomFactory.php 0000666 00000001663 15165375612 0012111 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Zoom; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Zoom\ZoomMeeting; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class ZoomFactory * * @package AmeliaBooking\Domain\Factory\Zoom */ class ZoomFactory { /** * @param $data * * @return ZoomMeeting * @throws InvalidArgumentException */ public static function create($data) { $zoomMeeting = new ZoomMeeting(); if (isset($data['id'])) { $zoomMeeting->setId(new Id($data['id'])); } if (isset($data['joinUrl'])) { $zoomMeeting->setJoinUrl(new Url($data['joinUrl'])); } if (isset($data['startUrl'])) { $zoomMeeting->setStartUrl(new Url($data['startUrl'])); } return $zoomMeeting; } } ValueObjects/DiscountFixedValue.php 0000666 00000002120 15165375612 0013422 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class DiscountFixedValue * * @package AmeliaBooking\Domain\ValueObjects */ final class DiscountFixedValue { /** * @var string */ private $value; /** * DiscountFixedValue constructor. * * @param string $value * * @throws InvalidArgumentException */ public function __construct($value) { if ($value === null) { throw new InvalidArgumentException('Discount can\'t be empty'); } if (filter_var($value, FILTER_VALIDATE_FLOAT) === false) { throw new InvalidArgumentException("Discount \"{$value}\" must be float"); } if ($value < 0) { throw new InvalidArgumentException('Discount must be larger then or equal to 0'); } $this->value = (float)$value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/String/EntityType.php 0000666 00000001161 15165375612 0013245 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Entity\Entities; /** * Class EntityType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class EntityType { const SERVICE = Entities::SERVICE; /** * @var string */ private $type; /** * Status constructor. * * @param int $type */ public function __construct($type) { $this->type = $type; } /** * Return the type from the value object * * @return string */ public function getValue() { return $this->type; } } ValueObjects/String/NotificationType.php 0000666 00000001525 15165375612 0014423 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class NotificationType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class NotificationType { const EMAIL = 'email'; const SMS = 'sms'; const WHATSAPP = 'whatsapp'; /** * @var string */ private $notificationType; /** * NotificationType constructor. * * @param string $notificationType */ public function __construct($notificationType) { $this->notificationType = $notificationType; } /** * Return the notification type from the value object * * @return string */ public function getValue() { return $this->notificationType; } } ValueObjects/String/CustomFieldType.php 0000666 00000001371 15165375612 0014212 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class PaymentType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class CustomFieldType { const TEXT = 'text'; const TEXTAREA = 'text-area'; const SELECT = 'select'; const CHECKBOX = 'checkbox'; const RADIO = 'radio'; const CONTENT = 'content'; const ADDRESS = 'address'; /** * @var string */ private $type; /** * Status constructor. * * @param int $type */ public function __construct($type) { $this->type = $type; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->type; } } ValueObjects/String/Status.php 0000666 00000001204 15165375612 0012410 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class Status * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Status { const HIDDEN = 'hidden'; const VISIBLE = 'visible'; const DISABLED = 'disabled'; /** * @var string */ private $status; /** * Status constructor. * * @param string $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/Password.php 0000666 00000003116 15165375612 0012733 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Password * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Password { const MIN_LENGTH = 4; const MAX_LENGTH = 128; /** * @var string */ private $password; /** * Email constructor. * * @param string $password * * @throws InvalidArgumentException */ public function __construct($password) { if ($password && strlen($password) < static::MIN_LENGTH) { throw new InvalidArgumentException('Password must be longer than ' . static::MIN_LENGTH . ' char'); } $this->password = password_hash($password, PASSWORD_DEFAULT); } /** * Create a Password value object from an hashed password * * @param string $password * * @return Password */ public static function createFromHashedPassword($password) { $self = unserialize(sprintf('O:%u:"%s":0:{}', strlen(self::class), self::class)); $self->password = $password; return $self; } /** * Return true if password is valid, otherwise false * * @param string $password * * @return bool */ public function checkValidity($password) { return password_verify($password, $this->password ? $this->password : ''); } /** * Return the password from the value object * * @return string */ public function getValue() { return $this->password; } } ValueObjects/String/Token.php 0000666 00000001277 15165375612 0012217 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class Token * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Token { const MAX_LENGTH = 10; /** * @var string */ private $token; /** * Token constructor. * * @param string $token * @param mixed $maxLength */ public function __construct($token = null, $maxLength = self::MAX_LENGTH) { $this->token = $token ?: bin2hex(openssl_random_pseudo_bytes(floor($maxLength / 2))); } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->token; } } ValueObjects/String/PaymentStatus.php 0000666 00000001231 15165375612 0013746 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class PaymentStatus * * @package AmeliaBooking\Domain\ValueObjects\String */ final class PaymentStatus { const PAID = 'paid'; const PENDING = 'pending'; const PARTIALLY_PAID = 'partiallyPaid'; /** * @var string */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/Phone.php 0000666 00000001551 15165375612 0012203 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Phone * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Phone { const MAX_LENGTH = 63; /** * @var string */ private $phone; /** * Phone constructor. * * @param string $phone * * @throws InvalidArgumentException */ public function __construct($phone) { if ($phone && strlen($phone) > static::MAX_LENGTH) { throw new InvalidArgumentException("Phone '$phone' must be less than " . static::MAX_LENGTH . ' chars'); } $this->phone = $phone; } /** * Return the phone from the value object * * @return string */ public function getValue() { return $this->phone; } } ValueObjects/String/Email.php 0000666 00000002030 15165375612 0012152 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Email * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Email { const MAX_LENGTH = 255; /** * @var string */ private $email; /** * Email constructor. * * @param string $email * * @throws InvalidArgumentException */ public function __construct($email) { if ($email !== null && !filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new InvalidArgumentException("Email '$email' is not a valid email"); } if ($email && strlen($email) > static::MAX_LENGTH) { throw new InvalidArgumentException("Email '$email' must be less than " . static::MAX_LENGTH . ' chars'); } $this->email = $email; } /** * Return the email from the value object * * @return string */ public function getValue() { return $this->email; } } ValueObjects/String/Address.php 0000666 00000001603 15165375612 0012515 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Address * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Address { const MAX_LENGTH = 255; /** * @var string */ private $address; /** * Address constructor. * * @param string $address * * @throws InvalidArgumentException */ public function __construct($address) { if ($address && strlen($address) > static::MAX_LENGTH) { throw new InvalidArgumentException("Name '$address' must be less than " . static::MAX_LENGTH . ' chars'); } $this->address = $address; } /** * Return the address from the value object * * @return string */ public function getValue() { return $this->address; } } ValueObjects/String/Cycle.php 0000666 00000001221 15165375612 0012163 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class Cycle * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Cycle { const DAILY = 'daily'; const WEEKLY = 'weekly'; const MONTHLY = 'monthly'; const YEARLY = 'yearly'; /** * @var string */ private $cycle; /** * Cycle constructor. * * @param string $cycle */ public function __construct($cycle) { $this->cycle = $cycle; } /** * Return the cycle from the value object * * @return string */ public function getValue() { return $this->cycle; } } ValueObjects/String/BookingStatus.php 0000666 00000001317 15165375612 0013726 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class Status * * @package AmeliaBooking\Domain\ValueObjects\String */ final class BookingStatus { const CANCELED = 'canceled'; const APPROVED = 'approved'; const PENDING = 'pending'; const REJECTED = 'rejected'; const NO_SHOW = 'no-show'; /** * @var string */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/DepositType.php 0000666 00000001221 15165375612 0013375 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class DepositType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class DepositType { const DISABLED = 'disabled'; const FIXED = 'fixed'; const PERCENTAGE = 'percentage'; /** * @var string */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/PaymentType.php 0000666 00000001340 15165375612 0013405 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class PaymentType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class PaymentType { const PAY_PAL = 'payPal'; const STRIPE = 'stripe'; const ON_SITE = 'onSite'; const WC = 'wc'; const MOLLIE = 'mollie'; const RAZORPAY = 'razorpay'; /** * @var string */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/Html.php 0000666 00000001620 15165375612 0012033 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Html * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Html { const MAX_LENGTH = 65535; /** * @var string */ private $html; /** * Description constructor. * * @param string $html * * @throws InvalidArgumentException */ public function __construct($html) { if ($html && strlen($html) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Description \"{$html}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->html = $html; } /** * Return the html from the value object * * @return string */ public function getValue() { return $this->html; } } ValueObjects/String/Color.php 0000666 00000001762 15165375612 0012214 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Color * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Color { const MAX_LENGTH = 255; /** * @var string */ private $color; /** * Name constructor. * * @param string $color * * @throws InvalidArgumentException */ public function __construct($color) { if (empty($color)) { throw new InvalidArgumentException("Color can't be empty"); } if (strlen($color) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Color \"{$color}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->color = $color; } /** * Return the color from the value object * * @return string */ public function getValue() { return $this->color; } } ValueObjects/String/Url.php 0000666 00000001574 15165375612 0011701 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Url * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Url { const MAX_LENGTH = 65535; /** * @var string */ private $url; /** * Description constructor. * * @param string $url * * @throws InvalidArgumentException */ public function __construct($url) { if ($url && strlen($url) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Url \"{$url}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->url = $url; } /** * Return the url from the value object * * @return string */ public function getValue() { return $this->url; } } ValueObjects/String/Description.php 0000666 00000002117 15165375612 0013414 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Description * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Description { const MAX_LENGTH = 4095; /** * @var string */ private $description; /** * Description constructor. * * @param string $description * * @throws InvalidArgumentException */ public function __construct($description) { if ($description && strlen($description) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Description \"{$description}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->description = $description; } /** * Return the description from the value object * * @return string */ public function getValue() { return $this->description; } } ValueObjects/String/BookingType.php 0000666 00000001511 15165375612 0013360 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Entity\Entities; /** * Class BookingType * * @package AmeliaBooking\Domain\ValueObjects\String */ final class BookingType { const APPOINTMENT = Entities::APPOINTMENT; const EVENT = Entities::EVENT; /** * @var string */ private $bookingType; /** * BookingType constructor. * * @param string $bookingType */ public function __construct($bookingType) { $this->bookingType = $bookingType; } /** * Return the notification type from the value object * * @return string */ public function getValue() { return $this->bookingType; } } ValueObjects/String/PaymentData.php 0000666 00000002121 15165375612 0013333 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class PaymentData * * @package AmeliaBooking\Domain\ValueObjects\String */ final class PaymentData { const MAX_LENGTH = 4095; /** * @var string */ private $paymentData; /** * PaymentData constructor. * * @param string $paymentData * * @throws InvalidArgumentException */ public function __construct($paymentData) { if ($paymentData && strlen($paymentData) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Payment data \"{$paymentData}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->paymentData = $paymentData; } /** * Return the payment data from the value object * * @return string */ public function getValue() { return $this->paymentData; } } ValueObjects/String/Label.php 0000666 00000001553 15165375612 0012153 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Label * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Label { const MAX_LENGTH = 65535; /** * @var string */ private $label; /** * Name constructor. * * @param string $label * * @throws InvalidArgumentException */ public function __construct($label) { if ($label && strlen($label) > static::MAX_LENGTH) { throw new InvalidArgumentException("Label '$label' must be less than " . static::MAX_LENGTH . ' chars'); } $this->label = $label; } /** * Return the name from the value object * * @return string */ public function getValue() { return $this->label; } } ValueObjects/String/Name.php 0000666 00000001623 15165375612 0012012 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Name * * @package AmeliaBooking\Domain\ValueObjects\String */ final class Name { const MAX_LENGTH = 255; /** * @var string */ private $name; /** * Name constructor. * * @param string $name * * @throws InvalidArgumentException */ public function __construct($name) { if (empty($name)) { $name = ''; } if (strlen($name) > static::MAX_LENGTH) { throw new InvalidArgumentException("Name '$name' must be less than " . static::MAX_LENGTH . ' chars'); } $this->name = $name; } /** * Return the name from the value object * * @return string */ public function getValue() { return $this->name; } } ValueObjects/String/NotificationStatus.php 0000666 00000001175 15165375612 0014766 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class NotificationStatus * * @package AmeliaBooking\Domain\ValueObjects\String */ final class NotificationStatus { const ENABLED = 'enabled'; const DISABLED = 'disabled'; /** * @var string */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = $status; } /** * Return the status from the value object * * @return string */ public function getValue() { return $this->status; } } ValueObjects/String/NotificationSendTo.php 0000666 00000001512 15165375612 0014672 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\String; /** * Class NotificationSendTo * * @package AmeliaBooking\Domain\ValueObjects\String */ final class NotificationSendTo { const CUSTOMER = 'customer'; const PROVIDER = 'provider'; /** * @var string */ private $notificationSendTo; /** * NotificationSendTo constructor. * * @param $notificationSendTo */ public function __construct($notificationSendTo) { $this->notificationSendTo = $notificationSendTo; } /** * Return the notification send to from the value object * * @return string */ public function getValue() { return $this->notificationSendTo; } } ValueObjects/String/CouponCode.php 0000666 00000001567 15165375612 0013177 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\String; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class CouponCode * * @package AmeliaBooking\Domain\ValueObjects\String */ final class CouponCode { const MAX_LENGTH = 255; /** * @var string */ private $value; /** * CouponCode constructor. * * @param string $value * * @throws InvalidArgumentException */ public function __construct($value) { if ($value && strlen($value) > static::MAX_LENGTH) { throw new InvalidArgumentException("Code '$value' must be less than " . static::MAX_LENGTH . ' chars'); } $this->value = $value; } /** * Return the code from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/Picture.php 0000666 00000003300 15165375612 0011271 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Picture * * @package AmeliaBooking\Domain\ValueObjects */ final class Picture { const MAX_LENGTH = 767; /** * @var string */ private $pathToFull; /** * @var string */ private $pathToThumb; /** * Name constructor. * * @param string $pathToFull * @param string $pathToThumb * * @throws InvalidArgumentException */ public function __construct($pathToFull, $pathToThumb) { if (empty($pathToFull)) { throw new InvalidArgumentException("Path to full can't be empty"); } if (strlen($pathToFull) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Path to full \"{$pathToFull}\" must be less than " . static::MAX_LENGTH . ' chars' ); } if (empty($pathToThumb)) { throw new InvalidArgumentException("Path to thumb can't be empty"); } if (strlen($pathToThumb) > static::MAX_LENGTH) { throw new InvalidArgumentException( "Path to thumb string length \"{$pathToThumb}\" must be less than " . static::MAX_LENGTH . ' chars' ); } $this->pathToFull = $pathToFull; $this->pathToThumb = $pathToThumb; } /** * Return the Full path * * @return string */ public function getFullPath() { return $this->pathToFull; } /** * Return the Thumb path * * @return string */ public function getThumbPath() { return $this->pathToThumb; } } ValueObjects/Recurring.php 0000666 00000010061 15165375612 0011620 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\Cycle; /** * Class Recurring * * @package AmeliaBooking\Domain\ValueObjects */ final class Recurring { /** * @var Cycle */ private $cycle; /** * @var WholeNumber */ private $cycleInterval; /** * @var string */ private $monthlyRepeat; /** * @var string */ private $monthlyOnRepeat; /** * @var string */ private $monthlyOnDay; /** * @var DateTimeValue */ private $monthDate; /** * @var WholeNumber */ private $order; /** * @var DateTimeValue */ private $until; /** * Recurring constructor. * * @param Cycle $cycle */ public function __construct(Cycle $cycle) { $this->cycle = $cycle; } /** * @param Cycle $cycle */ public function setCycle(Cycle $cycle) { $this->cycle = $cycle; } /** * Return the recurring cycle * * @return Cycle */ public function getCycle() { return $this->cycle; } /** * @return WholeNumber */ public function getCycleInterval() { return $this->cycleInterval; } /** * @param WholeNumber $cycleInterval */ public function setCycleInterval($cycleInterval) { $this->cycleInterval = $cycleInterval; } /** * @return string */ public function getMonthlyRepeat() { return $this->monthlyRepeat; } /** * @param string $monthlyRepeat */ public function setMonthlyRepeat($monthlyRepeat) { $this->monthlyRepeat = $monthlyRepeat; } /** * @return string */ public function getMonthlyOnRepeat() { return $this->monthlyOnRepeat; } /** * @param string $monthlyOnRepeat */ public function setMonthlyOnRepeat($monthlyOnRepeat) { $this->monthlyOnRepeat = $monthlyOnRepeat; } /** * @return string */ public function getMonthlyOnDay() { return $this->monthlyOnDay; } /** * @param string $monthlyOnDay */ public function setMonthlyOnDay($monthlyOnDay) { $this->monthlyOnDay = $monthlyOnDay; } /** * @return DateTimeValue */ public function getMonthDate() { return $this->monthDate; } /** * @param DateTimeValue $monthDate */ public function setMonthDate($monthDate) { $this->monthDate = $monthDate; } /** * @param WholeNumber $order */ public function setOrder(WholeNumber $order) { $this->order = $order; } /** * Return the recurring order * * @return WholeNumber */ public function getOrder() { return $this->order; } /** * @param DateTimeValue $until */ public function setUntil(DateTimeValue $until) { $this->until = $until; } /** * Return the recurring end * * @return DateTimeValue */ public function getUntil() { return $this->until; } /** * @return array */ public function toArray() { return [ 'cycle' => $this->getCycle()->getValue(), 'order' => $this->getOrder() ? $this->getOrder()->getValue() : null, 'until' => $this->getUntil() ? $this->getUntil()->getValue()->format('Y-m-d H:i:s') : null, 'cycleInterval' => $this->getCycleInterval() ? $this->getCycleInterval()->getValue() : null, 'monthlyRepeat' => $this->getMonthlyRepeat(), 'monthDate' => $this->getMonthDate() ? $this->getMonthDate()->getValue()->format('Y-m-d H:i:s') : null, 'monthlyOnRepeat' => $this->getMonthlyOnRepeat(), 'monthlyOnDay' => $this->getMonthlyOnDay() ]; } } ValueObjects/GeoTag.php 0000666 00000002737 15165375612 0011041 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class GeoTag * * @package AmeliaBooking\Domain\ValueObjects */ final class GeoTag { /** * @var float */ private $latitude; /** * @var float */ private $longitude; /** * GeoTag constructor. * * @param $latitude * @param $longitude * * @throws InvalidArgumentException */ public function __construct($latitude, $longitude) { if (empty($latitude)) { throw new InvalidArgumentException("Latitude can't be empty"); } $this->latitude = (float)$latitude; if (empty($longitude)) { throw new InvalidArgumentException("Longitude can't be empty"); } $this->longitude = (float)$longitude; } /** * Return the latitude from the value object * * @return float */ public function getLatitude() { return $this->latitude; } /** * Return the longitude from the value object * * @return float */ public function getLongitude() { return $this->longitude; } /** * Return array with longitude and latitude from value object * * @return array */ public function getValue() { return [ 'latitude' => $this->getLatitude(), 'longitude' => $this->getLongitude() ]; } } ValueObjects/Json.php 0000666 00000001044 15165375612 0010572 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects; /** * Class Json * * @package AmeliaBooking\Domain\ValueObjects */ final class Json { /** * @var string */ private $value; /** * @param string $value */ public function __construct($value) { $this->value = $value; } /** * @return string */ public function getValue() { return $this->value; } } ValueObjects/Gender.php 0000666 00000001526 15165375612 0011072 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Gender * * @package AmeliaBooking\Domain\ValueObjects */ final class Gender { const GENDER_MALE = 'male'; const GENDER_FEMALE = 'female'; /** * @var string */ private $value; /** * @param string $value * * @throws InvalidArgumentException */ public function __construct($value) { if (!in_array($value, [self::GENDER_MALE, self::GENDER_FEMALE, null], true)) { throw new InvalidArgumentException('Not valid gender option'); } $this->value = $value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/DiscountPercentageValue.php 0000666 00000002147 15165375612 0014451 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class DiscountPercentageValue * * @package AmeliaBooking\Domain\ValueObjects */ final class DiscountPercentageValue { /** * @var string */ private $value; /** * DiscountPercentageValue constructor. * * @param string $value * * @throws InvalidArgumentException */ public function __construct($value) { if ($value === null) { throw new InvalidArgumentException('Discount can\'t be empty'); } if (filter_var($value, FILTER_VALIDATE_FLOAT) === false) { throw new InvalidArgumentException("Discount \"{$value}\" must be float"); } if ($value < 0 || $value > 100) { throw new InvalidArgumentException('Discount must be between 0 and 100'); } $this->value = (float)$value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/DateTime/Birthday.php 0000666 00000001747 15165375612 0013135 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\DateTime; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; /** * Class Birthday * * @package AmeliaBooking\Domain\ValueObjects\DateTime */ final class Birthday { /** * @var string */ private $date; /** * Birthday Date constructor. * * @param \DateTime $date * * @throws InvalidArgumentException */ public function __construct(\DateTime $date) { if (null === $date) { throw new InvalidArgumentException("Date can't be empty"); } if (!($date instanceof \DateTime)) { throw new InvalidArgumentException('Date must be a instance of DateTime'); } $this->date = $date; } /** * Return the name from the value object * * @return \DateTime */ public function getValue() { return $this->date; } } ValueObjects/DateTime/TimeOfDay.php 0000666 00000002561 15165375612 0013203 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects\DateTime; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class TimeOfDay * * @package AmeliaBooking\Domain\ValueObjects\DateTime */ final class TimeOfDay { /** @var bool */ private $value; /** * TimeOfDay constructor. * * @param $value * * @throws InvalidArgumentException */ public function __construct($value) { $time = strtotime($value); $hour = (int)date('H', $time); $minute = (int)date('i', $time); $second = (int)date('s', $time); if ($hour < 0 || $hour > 24) { throw new InvalidArgumentException(sprintf('%s should be in range %d-%d', '$hour', 0, 24)); } if ($minute < 0 || $minute > 59) { throw new InvalidArgumentException(sprintf('%s should be in range %d-%d', '$minute', 0, 59)); } if ($second < 0 || $second > 59) { throw new InvalidArgumentException(sprintf('%s should be in range %d-%d', '$second', 0, 59)); } $this->value = $value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/DateTime/DateTimeValue.php 0000666 00000001665 15165375612 0014057 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\DateTime; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class DateTimeValue * * @package AmeliaBooking\Domain\ValueObjects\DateTime */ final class DateTimeValue { /** * @var string */ private $date; /** * Birthday Date constructor. * * @param \DateTime $date * * @throws InvalidArgumentException */ public function __construct(\DateTime $date) { if (null === $date) { throw new InvalidArgumentException("Date can't be empty"); } if (!($date instanceof \DateTime)) { throw new InvalidArgumentException('Date must be a instance of DateTime'); } $this->date = $date; } /** * Return the name from the value object * * @return \DateTime */ public function getValue() { return $this->date; } } ValueObjects/Priority.php 0000666 00000002160 15165375612 0011502 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Priority * * @package AmeliaBooking\Domain\ValueObjects */ final class Priority { const LEAST_EXPENSIVE = 'least_expensive'; const MOST_EXPENSIVE = 'most_expensive'; const LEAST_OCCUPIED = 'least_occupied'; const MOST_OCCUPIED = 'most_occupied'; /** * @var int */ private $value; /** * @param string $value * * @throws InvalidArgumentException */ public function __construct($value) { if (!in_array( $value, [ self::LEAST_EXPENSIVE, self::MOST_EXPENSIVE, self::LEAST_OCCUPIED, self::MOST_OCCUPIED ], false )) { throw new InvalidArgumentException('Not valid priority option'); } $this->value = $value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/Discount.php 0000666 00000002117 15165375612 0011453 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects; /** * Class Discount * * @package AmeliaBooking\Domain\ValueObjects */ final class Discount { const PERCENTAGE = 1; const FIXED = 2; /** @var int|null */ private $id; /** @var float */ private $amount; /** @var int */ private $type; /** * Discount constructor. * * @param float $amount * @param int $type */ public function __construct($amount, $type = self::PERCENTAGE) { $this->amount = $amount; $this->type = (int)$type; } /** * @return float */ public function getAmount() { return $this->amount; } /** * @return int */ public function getType() { return $this->type; } /** * @return array */ public function toArray() { return [ 'amount' => $this->getAmount(), 'type' => $this->getType(), ]; } } ValueObjects/BooleanValueObject.php 0000666 00000001167 15165375612 0013372 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\ValueObjects; /** * Class BooleanValueObject * * @package AmeliaBooking\Domain\ValueObjects */ final class BooleanValueObject { /** * @var bool */ private $value; /** * @param bool $value */ public function __construct($value) { $this->value = (bool)$value; } /** * Return the value from the value object * * @return string */ public function getValue() { return $this->value; } } ValueObjects/Duration.php 0000666 00000001317 15165375612 0011451 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class Duration * * @package AmeliaBooking\Domain\ValueObjects */ final class Duration { /** * @var WholeNumber */ private $duration; /** * Duration constructor. * * @param $duration * * @throws InvalidArgumentException */ public function __construct( $duration ) { $this->duration = new WholeNumber($duration); } /** * @return int */ public function getValue() { return $this->duration->getValue(); } } ValueObjects/PositiveDuration.php 0000666 00000001443 15165375612 0013174 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; /** * Class PositiveDuration * * @package AmeliaBooking\Domain\ValueObjects */ final class PositiveDuration { /** * @var PositiveInteger */ private $positiveDuration; /** * PositiveDuration constructor. * * @param $positiveDuration * * @throws InvalidArgumentException */ public function __construct( $positiveDuration ) { $this->positiveDuration = new PositiveInteger($positiveDuration); } /** * @return int */ public function getValue() { return $this->positiveDuration->getValue(); } } ValueObjects/Number/Float/FloatValue.php 0000666 00000001652 15165375612 0014225 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Float; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class FloatValue * * @package AmeliaBooking\Domain\ValueObjects\Number\Float */ final class FloatValue { /** * @var string */ private $float; /** * Name constructor. * * @param string $float * * @throws InvalidArgumentException */ public function __construct($float) { if (empty($float)) { throw new InvalidArgumentException("Float can't be empty"); } if (!filter_var($float, FILTER_VALIDATE_FLOAT)) { throw new InvalidArgumentException("Float '$float' must be float"); } $this->float = $float; } /** * Return the float from the value object * * @return string */ public function getValue() { return $this->float; } } ValueObjects/Number/Float/Price.php 0000666 00000002244 15165375612 0013223 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Float; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class Price * * @package AmeliaBooking\Domain\ValueObjects\Number\Float */ final class Price { /** * @var string */ private $price; /** * Price constructor. * * @param string $price * * @throws InvalidArgumentException */ public function __construct($price) { if ($price === null) { throw new InvalidArgumentException('Price can\'t be empty'); } if (filter_var($price, FILTER_VALIDATE_FLOAT) === false && filter_var(str_replace(',', '.', (string)$price), FILTER_VALIDATE_FLOAT) === false ) { throw new InvalidArgumentException("Price \"{$price}\" must be float"); } if ($price < 0) { throw new InvalidArgumentException('Price must be larger then or equal to 0'); } $this->price = (float)$price; } /** * Return the price from the value object * * @return float */ public function getValue() { return $this->price; } } ValueObjects/Number/Integer/Status.php 0000666 00000001344 15165375612 0013774 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; /** * Class Status * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class Status { const INVISIBLE = 0; const VISIBLE = 1; /** * @var int */ private $status; /** * Status constructor. * * @param int $status */ public function __construct($status) { $this->status = (int)$status; } /** * Return the status from the value object * * @return int */ public function getValue() { return $this->status; } /** * @return bool */ public function isVisible() { return $this->status === self::VISIBLE; } } ValueObjects/Number/Integer/PositiveInteger.php 0000666 00000001564 15165375612 0015635 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class PositiveInteger * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class PositiveInteger { /** * @var string */ private $integer; /** * @param string $integer * * @throws InvalidArgumentException */ public function __construct($integer) { if (filter_var($integer, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]) === false) { throw new InvalidArgumentException("Number '$integer' must be greater than zero"); } $this->integer = (int)$integer; } /** * Return the number from the value object * * @return int */ public function getValue() { return $this->integer; } } ValueObjects/Number/Integer/LoginType.php 0000666 00000001264 15165375612 0014424 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; /** * Class LoginType * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class LoginType { const WP_CREDENTIALS = 1; const WP_USER = 2; const AMELIA_CREDENTIALS = 3; const AMELIA_URL_TOKEN = 4; /** * @var int */ private $type; /** * Status constructor. * * @param int $type */ public function __construct($type) { $this->type = (int)$type; } /** * Return the type from the value object * * @return int */ public function getValue() { return $this->type; } } ValueObjects/Number/Integer/Capacity.php 0000666 00000001554 15165375612 0014251 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; final class Capacity { const MIN = 1; const MAX = 10; /** * @var string */ private $capacity; /** * Capacity constructor. * * @param string $capacity * * @throws InvalidArgumentException */ public function __construct($capacity) { if (!filter_var($capacity, FILTER_VALIDATE_INT)) { throw new InvalidArgumentException("Capacity '$capacity' must be whole number between " . self::MIN . ' and ' . self::MAX); } $this->capacity = (int)$capacity; } /** * Return the capacity from the value object * * @return int */ public function getValue() { return $this->capacity; } } ValueObjects/Number/Integer/WholeNumber.php 0000666 00000001542 15165375612 0014740 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class WholeNumber * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class WholeNumber { /** * @var string */ private $integer; /** * @param string $integer * * @throws InvalidArgumentException */ public function __construct($integer) { if (filter_var($integer, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) === false) { throw new InvalidArgumentException("Number '$integer' must be integer"); } $this->integer = (int)$integer; } /** * Return the number from the value object * * @return int */ public function getValue() { return $this->integer; } } ValueObjects/Number/Integer/IntegerValue.php 0000666 00000001506 15165375612 0015103 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class IntegerValue * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class IntegerValue { /** * @var string */ private $integer; /** * @param string $integer * * @throws InvalidArgumentException */ public function __construct($integer) { if (filter_var($integer, FILTER_VALIDATE_INT) === false) { throw new InvalidArgumentException("Number '$integer' must be whole number"); } $this->integer = (int)$integer; } /** * Return the number from the value object * * @return int */ public function getValue() { return $this->integer; } } ValueObjects/Number/Integer/DateRepeat.php 0000666 00000001336 15165375612 0014530 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; /** * Class DateRepeat * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class DateRepeat { const ON = 1; const OFF = 0; /** * @var int */ private $repeat; /** * repeat constructor. * * @param int $repeat */ public function __construct($repeat) { $this->repeat = (int)$repeat; } /** * Return the repeat from the value object * * @return int */ public function getValue() { return $this->repeat; } /** * @return bool */ public function isRepeating() { return $this->repeat === self::ON; } } ValueObjects/Number/Integer/Id.php 0000666 00000001021 15165375612 0013035 0 ustar 00 <?php namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; /** * Class Id * * @package AmeliaBooking\Domain\ValueObjects\Number\Integer */ final class Id { /** * @var int */ private $id; /** * Id constructor. * * @param int $id */ public function __construct($id) { $this->id = (int)$id; } /** * Return the password from the value object * * @return int */ public function getValue() { return $this->id; } } Services/Entity/EntityService.php 0000666 00000021601 15165375612 0013130 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Entity; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Extra; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\SlotsEntities; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Factory\Booking\SlotsEntitiesFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\Services\Resource\AbstractResourceService; use AmeliaBooking\Domain\Services\User\ProviderService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Duration; /** * Class EntityService * * @package AmeliaBooking\Domain\Services\Entity */ class EntityService { /** @var ProviderService */ private $providerService; /** @var AbstractResourceService */ private $resourceService; /** * EntityService constructor. * * @param ProviderService $providerService * @param AbstractResourceService $resourceService */ public function __construct( ProviderService $providerService, AbstractResourceService $resourceService ) { $this->providerService = $providerService; $this->resourceService = $resourceService; } /** * get filtered entities needed for slots calculation. * * @param array $settings * @param array $props * @param SlotsEntities $slotsEntities * * @return SlotsEntities * @throws InvalidArgumentException */ public function getFilteredSlotsEntities($settings, $props, $slotsEntities) { /** @var Collection $services */ $services = $slotsEntities->getServices() ?: new Collection(); /** @var Collection $providers */ $providers = $slotsEntities->getProviders() ?: new Collection(); /** @var Collection $locations */ $locations = $slotsEntities->getLocations() ?: new Collection(); /** @var Collection $filteredProviders */ $filteredProviders = new Collection(); /** @var Provider $provider */ foreach ($providers->getItems() as $provider) { if ($provider->getServiceList()->keyExists($props['serviceId'])) { if ($settings['allowAdminBookAtAnyTime']) { $this->providerService->setProvidersAlwaysAvailable( $providers ); } $this->providerService->setProviderServices( $provider, $services, false ); /** @var Service $service */ foreach ($provider->getServiceList()->getItems() as $service) { $this->checkServiceTimes($service); } $filteredProviders->addItem($provider, $provider->getId()->getValue()); } } /** @var Service $service */ foreach ($services->getItems() as $service) { $this->checkServiceTimes($service); } /** @var Collection $serviceResources */ $serviceResources = $slotsEntities->getResources() ? $this->resourceService->getServiceResources( $slotsEntities->getResources(), $props['serviceId'] ) : new Collection(); $this->resourceService->setNonSharedResources( $serviceResources, [ 'service' => $services->keys(), 'location' => $locations->keys(), ] ); /** @var SlotsEntities $filteredSlotsEntities */ $filteredSlotsEntities = SlotsEntitiesFactory::create(); $filteredSlotsEntities->setServices($services); $filteredSlotsEntities->setProviders($filteredProviders); $filteredSlotsEntities->setLocations($locations); $filteredSlotsEntities->setResources($serviceResources); return $filteredSlotsEntities; } /** * Add 0 as duration for service time before or time after if it is null * * @param Service $service * * @throws InvalidArgumentException */ private function checkServiceTimes($service) { if (!$service->getTimeBefore()) { $service->setTimeBefore(new Duration(0)); } if (!$service->getTimeAfter()) { $service->setTimeAfter(new Duration(0)); } } /** * filter appointments required for slots calculation * * @param SlotsEntities $slotsEntities * @param Collection $appointments * @param array $props * * @return void * @throws InvalidArgumentException */ public function filterSlotsAppointments($slotsEntities, $appointments, $props) { /** @var Collection $services */ $services = $slotsEntities->getServices(); /** @var Collection $providers */ $providers = $slotsEntities->getProviders(); $providersIds = $providers->keys(); /** @var Appointment $appointment */ foreach ($appointments->getItems() as $index => $appointment) { if (!in_array($appointment->getProviderId()->getValue(), $providersIds) || ( $props['excludeAppointmentId'] && $index === $props['excludeAppointmentId'] ) ) { $appointments->deleteItem($index); } } $lastIndex = null; /** @var Appointment $appointment */ foreach ($appointments->getItems() as $index => $appointment) { /** @var Provider $provider */ $provider = $providers->getItem($appointment->getProviderId()->getValue()); /** @var Service $providerService */ $providerService = $provider->getServiceList()->keyExists($appointment->getServiceId()->getValue()) ? $provider->getServiceList()->getItem($appointment->getServiceId()->getValue()) : $services->getItem($appointment->getServiceId()->getValue()); $appointment->setService($providerService); if ($lastIndex) { /** @var Appointment $previousAppointment */ $previousAppointment = $appointments->getItem($lastIndex); if (( $previousAppointment->getLocationId() && $appointment->getLocationId() ? $previousAppointment->getLocationId()->getValue() === $appointment->getLocationId()->getValue() : true ) && $previousAppointment->getProviderId()->getValue() === $appointment->getProviderId()->getValue() && $previousAppointment->getServiceId()->getValue() === $appointment->getServiceId()->getValue() && $providerService->getMaxCapacity()->getValue() === 1 && $appointment->getBookingStart()->getValue()->format('H:i') !== '00:00' && $previousAppointment->getBookingEnd()->getValue()->format('Y-m-d H:i') === $appointment->getBookingStart()->getValue()->format('Y-m-d H:i') ) { $previousAppointment->setBookingEnd( new DateTimeValue( DateTimeService::getCustomDateTimeObject( $appointment->getBookingEnd()->getValue()->format('Y-m-d H:i:s') ) ) ); $appointments->deleteItem($index); } else { $lastIndex = $index; } } else { $lastIndex = $index; } } } /** * Return required time for the appointment in seconds by summing service duration, service time before and after * and each passed extra. * * @param Service $service * @param array $selectedExtras * * @return mixed * @throws InvalidArgumentException */ public function getAppointmentRequiredTime($service, $selectedExtras) { $requiredTime = $service->getTimeBefore()->getValue() + $service->getDuration()->getValue() + $service->getTimeAfter()->getValue(); $extraIds = array_column($selectedExtras, 'id'); /** @var Extra $extra */ foreach ($service->getExtras()->getItems() as $extra) { if (in_array($extra->getId()->getValue(), $extraIds, false)) { if (!$extra->getDuration()) { $extra->setDuration(new Duration(0)); } $requiredTime += ($extra->getDuration()->getValue() * array_column($selectedExtras, 'quantity', 'id')[$extra->getId()->getValue()]); } } return $requiredTime; } } Services/Permissions/PermissionsService.php 0000666 00000011011 15165375612 0015220 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Permissions; use AmeliaBooking\Domain\Entity\User\AbstractUser; use AmeliaBooking\Domain\Entity\User\Admin; use AmeliaBooking\Infrastructure\Common\Container; /** * Class PermissionsService * * @package AmeliaBooking\Domain\Services\Permissions */ class PermissionsService { const READ_PERMISSIONS = 'read'; const READ_OTHERS_PERMISSIONS = 'read_others'; const WRITE_PERMISSIONS = 'write'; const DELETE_PERMISSIONS = 'delete'; const WRITE_STATUS_PERMISSIONS = 'write_status'; const WRITE_TIME_PERMISSIONS = 'write_time'; const WRITE_OTHERS_PERMISSIONS = 'write_others'; /** * @var AbstractUser */ private $currentUser; /** * @var PermissionsCheckerInterface */ private $permissionsChecker; /** * PermissionsService constructor. * * @param Container $container * @param PermissionsCheckerInterface $permissionsChecker * * @throws \Slim\Exception\ContainerValueNotFoundException * @throws \InvalidArgumentException * @throws \Interop\Container\Exception\ContainerException */ public function __construct(Container $container, PermissionsCheckerInterface $permissionsChecker) { // Inject dependencies if (!($permissionsChecker instanceof PermissionsCheckerInterface)) { throw new \InvalidArgumentException('Permissions checker must implement PermissionsCheckerInterface!'); } // Assign current user reference $this->currentUser = $container->get('logged.in.user'); $this->permissionsChecker = $permissionsChecker; } /** * @param $user * @param $object * @param $permission * * @return bool|mixed */ public function userCan($user, $object, $permission) { if ($user instanceof Admin) { return true; } return $this->permissionsChecker->checkPermissions($user, $object, $permission); } /** * Checks if a given user (AbstractUser) can read a given entity * * @param AbstractUser $user * @param $object * * @return bool */ public function userCanRead(AbstractUser $user, $object) { return $this->userCan($user, $object, self::READ_PERMISSIONS); } /** * Checks if a given user (AbstractUser) can write a given entity * * @param AbstractUser $user * @param $object * * @return bool */ public function userCanWrite(AbstractUser $user, $object) { return $this->userCan($user, $object, self::WRITE_PERMISSIONS); } /** * Checks if a given user (AbstractUser) can delete a given entity * * @param AbstractUser $user * @param $object * * @return bool */ public function userCanDelete(AbstractUser $user, $object) { return $this->userCan($user, $object, self::DELETE_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanRead($object) { return $this->userCan($this->currentUser, $object, self::READ_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanReadOthers($object) { return $this->userCan($this->currentUser, $object, self::READ_OTHERS_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanWrite($object) { return $this->userCan($this->currentUser, $object, self::WRITE_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanWriteOthers($object) { return $this->userCan($this->currentUser, $object, self::WRITE_OTHERS_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanWriteStatus($object) { return $this->userCan($this->currentUser, $object, self::WRITE_STATUS_PERMISSIONS); } /** * @param $object * * @return bool */ public function currentUserCanWriteTime($object) { return $this->userCan($this->currentUser, $object, self::WRITE_TIME_PERMISSIONS); } /** * Checks if current user can delete an entity * * @param $object * * @return bool */ public function currentUserCanDelete($object) { return $this->userCan($this->currentUser, $object, self::DELETE_PERMISSIONS); } } Services/Permissions/PermissionsCheckerInterface.php 0000666 00000000604 15165375612 0017013 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Permissions; /** * Interface PermissionsCheckerInterface * * @package AmeliaBooking\Domain\Services\Permissions */ interface PermissionsCheckerInterface { /** * @param $user * @param $object * @param $permission * * @return mixed */ public function checkPermissions($user, $object, $permission); } Services/TimeSlot/TimeSlotService.php 0000666 00000131743 15165375612 0013711 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\TimeSlot; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Entity\Booking\SlotsEntities; use AmeliaBooking\Domain\Entity\Schedule\DayOff; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Services\Entity\EntityService; use AmeliaBooking\Domain\Services\Interval\IntervalService; use AmeliaBooking\Domain\Services\Resource\AbstractResourceService; use AmeliaBooking\Domain\Services\Schedule\ScheduleService; use AmeliaBooking\Domain\Services\User\ProviderService; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\String\Status; use DateInterval; use DatePeriod; use DateTime; use DateTimeZone; use Exception; /** * Class TimeSlotService * * @package AmeliaBooking\Domain\Services\TimeSlot */ class TimeSlotService { /** @var IntervalService */ private $intervalService; /** @var ScheduleService */ private $scheduleService; /** @var ProviderService */ private $providerService; /** @var AbstractResourceService */ private $resourceService; /** @var EntityService */ private $entityService; /** * TimeSlotService constructor. * * @param IntervalService $intervalService * @param ScheduleService $scheduleService * @param ProviderService $providerService * @param AbstractResourceService $resourceService * @param EntityService $entityService */ public function __construct( IntervalService $intervalService, ScheduleService $scheduleService, ProviderService $providerService, AbstractResourceService $resourceService, EntityService $entityService ) { $this->intervalService = $intervalService; $this->scheduleService = $scheduleService; $this->providerService = $providerService; $this->resourceService = $resourceService; $this->entityService = $entityService; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * get appointment intervals for provider. * * @param array $weekDaysIntervals * @param array $intervals * @param string $dateString * @param int $start * @param int $end * @return array */ private function getModifiedEndInterval($weekDaysIntervals, &$intervals, $dateString, $start, $end) { $dayIndex = DateTimeService::getDayIndex($dateString); if (isset($weekDaysIntervals[$dayIndex]['busy'][$start]) && $weekDaysIntervals[$dayIndex]['busy'][$start][1] > $end ) { $end = $weekDaysIntervals[$dayIndex]['busy'][$start][1]; } if (isset($intervals[$dateString]['occupied'][$start]) && $intervals[$dateString]['occupied'][$start][1] > $end ) { $end = $intervals[$dateString]['occupied'][$start][1]; } return $end; } /** * Split start and end in array of dates. * * @param DateTime $start * @param DateTime $end * * @return array */ private function getPeriodDates($start, $end) { /** @var DatePeriod $period */ $period = new DatePeriod( $start->setTime(0, 0, 0), new DateInterval('P1D'), $end ); $periodDates = []; /** @var DateTime $date */ foreach ($period as $index => $date) { $periodDates[] = $date->format('Y-m-d'); } return $periodDates; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * get appointment intervals for provider. * * @param Provider $provider * @param Collection $locations * @param int $serviceId * @param int $locationId * @param int $personsCount * @param boolean $bookIfPending * @param array $weekDaysIntervals * @param array $specialDaysIntervals * @return array * @throws InvalidArgumentException */ private function getProviderAppointmentIntervals( $provider, $locations, $serviceId, $locationId, $personsCount, $bookIfPending, &$weekDaysIntervals, &$specialDaysIntervals ) { $intervals = []; $specialDays = []; foreach ($specialDaysIntervals as $specialDay) { $specialDays = array_merge($specialDays, $specialDay['dates']); } /** @var Appointment $app */ foreach ($provider->getAppointmentList()->getItems() as $app) { $occupiedStart = $provider->getTimeZone() ? DateTimeService::getDateTimeObjectInTimeZone( $app->getBookingStart()->getValue()->format('Y-m-d H:i'), $provider->getTimeZone()->getValue() ) : DateTimeService::getCustomDateTimeObject($app->getBookingStart()->getValue()->format('Y-m-d H:i')); $occupiedEnd = $provider->getTimeZone() ? DateTimeService::getDateTimeObjectInTimeZone( $app->getBookingEnd()->getValue()->format('Y-m-d H:i'), $provider->getTimeZone()->getValue() ) : DateTimeService::getCustomDateTimeObject($app->getBookingEnd()->getValue()->format('Y-m-d H:i')); if ($app->getServiceId()->getValue()) { $occupiedStart->modify('-' . ($app->getService()->getTimeBefore() ? $app->getService()->getTimeBefore()->getValue() : 0) . ' seconds'); $occupiedEnd->modify('+' . ($app->getService()->getTimeAfter() ? $app->getService()->getTimeAfter()->getValue() : 0) . ' seconds'); } $occupiedDateStart = $occupiedStart->format('Y-m-d'); $occupiedSecondsStart = $this->intervalService->getSeconds($occupiedStart->format('H:i') . ':00'); $occupiedSecondsEnd = $this->intervalService->getSeconds($occupiedEnd->format('H:i:s')); if ($occupiedDateStart === $occupiedEnd->format('Y-m-d')) { $intervals[$occupiedDateStart]['occupied'][$occupiedSecondsStart] = [ $occupiedSecondsStart, $this->getModifiedEndInterval( !array_key_exists($occupiedDateStart, $specialDays) ? $weekDaysIntervals : [], $intervals, $occupiedDateStart, $occupiedSecondsStart, $occupiedSecondsEnd ) ]; } else { $dates = $this->getPeriodDates($occupiedStart, $occupiedEnd); $datesCount = sizeof($dates); if ($datesCount === 1) { $intervals[$dates[0]]['occupied'][$occupiedSecondsStart] = [ $occupiedSecondsStart, $occupiedSecondsEnd === 0 ? 86400 : $occupiedSecondsEnd ]; } else { foreach ($dates as $index => $date) { if ($index === 0) { $intervals[$date]['occupied'][$occupiedSecondsStart] = [$occupiedSecondsStart, 86400]; } elseif ($index === $datesCount - 1) { $modifiedEnd = $this->getModifiedEndInterval( !array_key_exists($occupiedDateStart, $specialDays) ? $weekDaysIntervals : [], $intervals, $date, 0, $occupiedSecondsEnd ); $intervals[$date]['occupied'][0] = [ 0, $modifiedEnd === 0 ? 86400 : $modifiedEnd ]; } else { $intervals[$date]['occupied'][0] = [0, 86400]; } } } } $providerLocationId = $provider->getLocationId() ? $provider->getLocationId()->getValue() : null; if ($app->getServiceId()->getValue() === $serviceId) { $persons = 0; /** @var CustomerBooking $booking */ foreach ($app->getBookings()->getItems() as $booking) { $persons += $booking->getPersons()->getValue(); } $status = $app->getStatus()->getValue(); $appLocationId = $app->getLocationId() ? $app->getLocationId()->getValue() : null; $hasCapacity = $personsCount !== null && ($persons + $personsCount) <= $app->getService()->getMaxCapacity()->getValue() && !($app->isFull() ? $app->isFull()->getValue() : false); $hasLocation = !$locationId || ($app->getLocationId() && $app->getLocationId()->getValue() === $locationId) || (!$app->getLocationId() && $providerLocationId === $locationId) || ($appLocationId && $appLocationId === $locationId && $locations->getItem($appLocationId)->getStatus()->getValue() === Status::VISIBLE) || (!$appLocationId && $providerLocationId && $locations->getItem($providerLocationId)->getStatus()->getValue() === Status::VISIBLE); if (($hasLocation && $status === BookingStatus::APPROVED && $hasCapacity) || ($hasLocation && $status === BookingStatus::PENDING && ($bookIfPending || $hasCapacity)) ) { $endDateTime = $app->getBookingEnd()->getValue()->format('Y-m-d H:i:s'); $endDateTimeParts = explode(' ', $endDateTime); $intervals[$occupiedDateStart]['available'][$app->getBookingStart()->getValue()->format('H:i')] = [ 'locationId' => $app->getLocationId() ? $app->getLocationId()->getValue() : $providerLocationId, 'places' => $app->getService()->getMaxCapacity()->getValue() - $persons, 'endDate' => $endDateTimeParts[0], 'endTime' => $endDateTimeParts[1], 'serviceId' => $serviceId, ]; } else { $intervals[$occupiedDateStart]['full'][$app->getBookingStart()->getValue()->format('H:i')] = [ 'locationId' => $app->getLocationId() ? $app->getLocationId()->getValue() : $providerLocationId, 'places' => $app->getService()->getMaxCapacity()->getValue() - $persons, 'end' => $app->getBookingEnd()->getValue()->format('Y-m-d H:i:s'), 'serviceId' => $app->getServiceId()->getValue(), ]; } } elseif ($app->getServiceId()->getValue()) { $intervals[$occupiedDateStart]['full'][$app->getBookingStart()->getValue()->format('H:i')] = [ 'locationId' => $app->getLocationId() ? $app->getLocationId()->getValue() : $providerLocationId, 'places' => 0, 'end' => $app->getBookingEnd()->getValue()->format('Y-m-d H:i:s'), 'serviceId' => $app->getServiceId()->getValue(), ]; } } return $intervals; } /** * get provider day off dates. * * @param Provider $provider * * @return array * @throws Exception */ private function getProviderDayOffDates($provider) { $dates = []; /** @var DayOff $dayOff */ foreach ($provider->getDayOffList()->getItems() as $dayOff) { $endDateCopy = clone $dayOff->getEndDate()->getValue(); $dayOffPeriod = new DatePeriod( $dayOff->getStartDate()->getValue(), new DateInterval('P1D'), $endDateCopy->modify('+1 day') ); /** @var DateTime $date */ foreach ($dayOffPeriod as $date) { $dateFormatted = $dayOff->getRepeat()->getValue() ? $date->format('m-d') : $date->format('Y-m-d'); $dates[$dateFormatted] = $dateFormatted; } } return $dates; } /** * get available appointment intervals. * * @param array $availableIntervals * @param array $unavailableIntervals * * @return array */ private function getAvailableIntervals(&$availableIntervals, $unavailableIntervals) { $parsedAvailablePeriod = []; ksort($availableIntervals); ksort($unavailableIntervals); foreach ($availableIntervals as $available) { $parsedAvailablePeriod[] = $available; foreach ($unavailableIntervals as $unavailable) { if ($parsedAvailablePeriod) { $lastAvailablePeriod = $parsedAvailablePeriod[sizeof($parsedAvailablePeriod) - 1]; if ($unavailable[0] >= $lastAvailablePeriod[0] && $unavailable[1] <= $lastAvailablePeriod[1]) { // unavailable interval is inside available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($fixedPeriod[0] !== $unavailable[0]) { $parsedAvailablePeriod[] = [$fixedPeriod[0], $unavailable[0], $fixedPeriod[2]]; } if ($unavailable[1] !== $fixedPeriod[1]) { $parsedAvailablePeriod[] = [$unavailable[1], $fixedPeriod[1], $fixedPeriod[2]]; } } elseif ($unavailable[0] <= $lastAvailablePeriod[0] && $unavailable[1] >= $lastAvailablePeriod[1]) { // available interval is inside unavailable interval array_pop($parsedAvailablePeriod); } elseif ($unavailable[0] <= $lastAvailablePeriod[0] && $unavailable[1] >= $lastAvailablePeriod[0] && $unavailable[1] <= $lastAvailablePeriod[1]) { // unavailable interval intersect start of available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($unavailable[1] !== $fixedPeriod[1]) { $parsedAvailablePeriod[] = [$unavailable[1], $fixedPeriod[1], $fixedPeriod[2]]; } } elseif ($unavailable[0] >= $lastAvailablePeriod[0] && $unavailable[0] <= $lastAvailablePeriod[1] && $unavailable[1] >= $lastAvailablePeriod[1]) { // unavailable interval intersect end of available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($fixedPeriod[0] !== $unavailable[0]) { $parsedAvailablePeriod[] = [$fixedPeriod[0], $unavailable[0], $fixedPeriod[2]]; } } } } } return $parsedAvailablePeriod; } /** * @param Service $service * @param Provider $provider * @param int $personsCount * * @return bool * * @throws Exception */ private function getOnlyAppointmentsSlots($service, $provider, $personsCount) { $getOnlyAppointmentsSlots = false; if ($provider->getServiceList()->keyExists($service->getId()->getValue())) { /** @var Service $providerService */ $providerService = $provider->getServiceList()->getItem($service->getId()->getValue()); if ($personsCount < $providerService->getMinCapacity()->getValue()) { $getOnlyAppointmentsSlots = true; } } return $getOnlyAppointmentsSlots; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param Service $service * @param int $locationId * @param Collection $providers * @param Collection $locations * @param array $globalDaysOffDates * @param DateTime $startDateTime * @param DateTime $endDateTime * @param int $personsCount * @param boolean $bookIfPending * @param boolean $bookIfNotMin * @param boolean $bookAfterMin * * @return array * @throws Exception */ private function getFreeTime( Service $service, $locationId, Collection $locations, Collection $providers, array $globalDaysOffDates, DateTime $startDateTime, DateTime $endDateTime, $personsCount, $bookIfPending, $bookIfNotMin, $bookAfterMin ) { $weekDayIntervals = []; $appointmentIntervals = []; $daysOffDates = []; $specialDayIntervals = []; $getOnlyAppointmentsSlots = []; $serviceId = $service->getId()->getValue(); /** @var Provider $provider */ foreach ($providers->getItems() as $provider) { $providerId = $provider->getId()->getValue(); $getOnlyAppointmentsSlots[$providerId] = $bookIfNotMin && $bookAfterMin ? $this->getOnlyAppointmentsSlots( $service, $provider, $personsCount ) : false; $daysOffDates[$providerId] = $this->getProviderDayOffDates($provider); $weekDayIntervals[$providerId] = $this->scheduleService->getProviderWeekDaysIntervals( $provider, $locations, $locationId, $serviceId ); $specialDayIntervals[$providerId] = $this->scheduleService->getProviderSpecialDayIntervals( $provider, $locations, $locationId, $serviceId ); $appointmentIntervals[$providerId] = $this->getProviderAppointmentIntervals( $provider, $locations, $serviceId, $locationId, $personsCount, $bookIfPending, $weekDayIntervals[$providerId], $specialDayIntervals[$providerId] ); } $freeDateIntervals = []; foreach ($appointmentIntervals as $providerKey => $providerDates) { foreach ((array)$providerDates as $dateKey => $dateIntervals) { $dayIndex = DateTimeService::getDayIndex($dateKey); $specialDayDateKey = null; foreach ((array)$specialDayIntervals[$providerKey] as $specialDayKey => $specialDays) { if (array_key_exists($dateKey, $specialDays['dates'])) { $specialDayDateKey = $specialDayKey; break; } } if ($specialDayDateKey !== null && isset($specialDayIntervals[$providerKey][$specialDayDateKey]['intervals']['free'])) { // get free intervals if it is special day $freeDateIntervals[$providerKey][$dateKey] = $this->getAvailableIntervals( $specialDayIntervals[$providerKey][$specialDayDateKey]['intervals']['free'], $dateIntervals['occupied'] ); } elseif (isset($weekDayIntervals[$providerKey][$dayIndex]['free']) && !isset($specialDayIntervals[$providerKey][$specialDayDateKey]['intervals'])) { // get free intervals if it is working day $unavailableIntervals = $weekDayIntervals[$providerKey][$dayIndex]['busy'] + $dateIntervals['occupied']; $intersectedTimes = array_intersect( array_keys($weekDayIntervals[$providerKey][$dayIndex]['busy']), array_keys($dateIntervals['occupied']) ); foreach ($intersectedTimes as $time) { $unavailableIntervals[$time] = $weekDayIntervals[$providerKey][$dayIndex]['busy'][$time] > $dateIntervals['occupied'][$time] ? $weekDayIntervals[$providerKey][$dayIndex]['busy'][$time] : $dateIntervals['occupied'][$time]; } $freeDateIntervals[$providerKey][$dateKey] = $this->getAvailableIntervals( $weekDayIntervals[$providerKey][$dayIndex]['free'], $unavailableIntervals ); } } } $startDateTime = clone $startDateTime; $startDateTime->setTime(0, 0); $endDateTime = clone $endDateTime; $endDateTime->modify('+1 day')->setTime(0, 0); // create calendar $period = new DatePeriod( $startDateTime, new DateInterval('P1D'), $endDateTime ); $calendar = []; /** @var DateTime $day */ foreach ($period as $day) { $currentDate = $day->format('Y-m-d'); $dayIndex = (int)$day->format('N'); $isGlobalDayOff = array_key_exists($currentDate, $globalDaysOffDates) || array_key_exists($day->format('m-d'), $globalDaysOffDates); if (!$isGlobalDayOff) { foreach ($weekDayIntervals as $providerKey => $providerWorkingHours) { $isProviderDayOff = array_key_exists($currentDate, $daysOffDates[$providerKey]) || array_key_exists($day->format('m-d'), $daysOffDates[$providerKey]); $specialDayDateKey = null; foreach ((array)$specialDayIntervals[$providerKey] as $specialDayKey => $specialDays) { if (array_key_exists($currentDate, $specialDays['dates'])) { $specialDayDateKey = $specialDayKey; break; } } if (!$isProviderDayOff) { if ($freeDateIntervals && isset($freeDateIntervals[$providerKey][$currentDate])) { // get date intervals if there are appointments (special or working day) $calendar[$currentDate][$providerKey] = [ 'slots' => $personsCount && $bookIfNotMin && isset($appointmentIntervals[$providerKey][$currentDate]['available']) ? $appointmentIntervals[$providerKey][$currentDate]['available'] : [], 'full' => isset($appointmentIntervals[$providerKey][$currentDate]['full']) ? $appointmentIntervals[$providerKey][$currentDate]['full'] : [], 'intervals' => $getOnlyAppointmentsSlots[$providerKey] ? [] : $freeDateIntervals[$providerKey][$currentDate], ]; } else { if ($specialDayDateKey !== null && isset($specialDayIntervals[$providerKey][$specialDayDateKey]['intervals']['free'])) { // get date intervals if it is special day with out appointments $calendar[$currentDate][$providerKey] = [ 'slots' => [], 'full' => [], 'intervals' => $getOnlyAppointmentsSlots[$providerKey] ? [] : $specialDayIntervals[$providerKey][$specialDayDateKey]['intervals']['free'] ]; } elseif (isset($weekDayIntervals[$providerKey][$dayIndex]) && !isset($specialDayIntervals[$providerKey][$specialDayDateKey]['intervals'])) { // get date intervals if it is working day without appointments $calendar[$currentDate][$providerKey] = [ 'slots' => [], 'full' => [], 'intervals' => $getOnlyAppointmentsSlots[$providerKey] ? [] : $weekDayIntervals[$providerKey][$dayIndex]['free'] ]; } } } } } } return $calendar; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param Service $service * @param int $requiredTime * @param array $freeIntervals * @param array $resourcedIntervals * @param int $slotLength * @param DateTime $startDateTime * @param bool $serviceDurationAsSlot * @param bool $bufferTimeInSlot * @param bool $isFrontEndBooking * @param String $timeZone * * @return array */ private function getAppointmentFreeSlots( $service, $requiredTime, &$freeIntervals, $resourcedIntervals, $slotLength, $startDateTime, $serviceDurationAsSlot, $bufferTimeInSlot, $isFrontEndBooking, $timeZone ) { $availableResult = []; $occupiedResult = []; $realRequiredTime = $requiredTime - $service->getTimeBefore()->getValue() - $service->getTimeAfter()->getValue(); if ($serviceDurationAsSlot && !$bufferTimeInSlot) { $requiredTime = $requiredTime - $service->getTimeBefore()->getValue() - $service->getTimeAfter()->getValue(); } $currentDateTime = DateTimeService::getNowDateTimeObject(); $currentDateString = $currentDateTime->format('Y-m-d'); $currentTimeStringInSeconds = $this->intervalService->getSeconds($currentDateTime->format('H:i:s')); $currentTimeInSeconds = $this->intervalService->getSeconds($currentDateTime->format('H:i:s')); $currentDateFormatted = $currentDateTime->format('Y-m-d'); $startTimeInSeconds = $this->intervalService->getSeconds($startDateTime->format('H:i:s')); $startDateFormatted = $startDateTime->format('Y-m-d'); $bookingLength = $serviceDurationAsSlot && $isFrontEndBooking ? $requiredTime : $slotLength; foreach ($freeIntervals as $dateKey => $dateProviders) { foreach ((array)$dateProviders as $providerKey => $provider) { foreach ((array)$provider['intervals'] as $timePeriod) { if ($timePeriod[1] === 86400) { $nextDateString = DateTimeService::getDateTimeObjectInTimeZone( $dateKey . ' 00:00:00', $timeZone )->modify('+1 days')->format('Y-m-d'); if (isset($freeIntervals[$nextDateString][$providerKey]['intervals'][0]) && $freeIntervals[$nextDateString][$providerKey]['intervals'][0][0] === 0 ) { $nextDayInterval = $freeIntervals[$nextDateString][$providerKey]['intervals'][0][1]; $timePeriod[1] += ($realRequiredTime <= $nextDayInterval ? $realRequiredTime : $nextDayInterval); } } if (!$bufferTimeInSlot && $serviceDurationAsSlot) { $timePeriod[1] = $timePeriod[1] - $service->getTimeAfter()->getValue(); } $customerTimeStart = $timePeriod[0] + $service->getTimeBefore()->getValue(); $providerTimeStart = $customerTimeStart - $service->getTimeBefore()->getValue(); $numberOfSlots = (int)(floor(($timePeriod[1] - $providerTimeStart - $requiredTime) / $bookingLength) + 1); $inspectResourceIndexes = []; if (isset($resourcedIntervals[$dateKey])) { foreach ($resourcedIntervals[$dateKey] as $resourceIndex => $resourceData) { if (array_intersect( $timePeriod[2], $resourcedIntervals[$dateKey][$resourceIndex]['locationsIds'] )) { $inspectResourceIndexes[] = $resourceIndex; } } } $providerPeriodSlots = []; $achievedLength = 0; for ($i = 0; $i < $numberOfSlots; $i++) { $achievedLength += $bookingLength; $timeSlot = $customerTimeStart + $i * $bookingLength; if (($startDateFormatted !== $dateKey && ($serviceDurationAsSlot && !$bufferTimeInSlot ? $timeSlot <= $timePeriod[1] - $requiredTime : true)) || ($startDateFormatted === $dateKey && $startTimeInSeconds < $timeSlot) || ($startDateFormatted === $currentDateFormatted && $startDateFormatted === $dateKey && $startTimeInSeconds < $timeSlot && $currentTimeInSeconds < $timeSlot) ) { $timeSlotEnd = $timeSlot + $bookingLength; $filteredLocationsIds = $timePeriod[2]; foreach ($inspectResourceIndexes as $resourceIndex) { foreach ($resourcedIntervals[$dateKey][$resourceIndex]['intervals'] as $start => $end) { if (($start >= $timeSlot && $start < $timeSlotEnd) || ($end > $timeSlot && $end <= $timeSlotEnd) || ($start <= $timeSlot && $end >= $timeSlotEnd) || ($start >= $timeSlot && $start < $timeSlot + $requiredTime) ) { $filteredLocationsIds = array_diff( $filteredLocationsIds, $resourcedIntervals[$dateKey][$resourceIndex]['locationsIds'] ); if (!$filteredLocationsIds) { if ($achievedLength < $requiredTime) { $providerPeriodSlots = []; $achievedLength = 0; } continue 3; } $removedLocationsIds = array_diff( $resourcedIntervals[$dateKey][$resourceIndex]['locationsIds'], $filteredLocationsIds ); if ($removedLocationsIds && $achievedLength < $requiredTime) { $parsedPeriodSlots = []; foreach ($providerPeriodSlots as $previousTimeSlot => $periodSlotData) { if ($start >= $previousTimeSlot && $start < $previousTimeSlot + $requiredTime ) { foreach ($periodSlotData as $data) { if (!in_array($data[1], $removedLocationsIds)) { $parsedPeriodSlots[$previousTimeSlot][] = $data; } } } else { $parsedPeriodSlots[$previousTimeSlot] = $periodSlotData; } } $providerPeriodSlots = $parsedPeriodSlots; } } } } if (!$timePeriod[2]) { $providerPeriodSlots[$timeSlot][] = [$providerKey, null]; } else if ($filteredLocationsIds) { foreach ($filteredLocationsIds as $locationId) { $providerPeriodSlots[$timeSlot][] = [$providerKey, $locationId]; } } } } foreach ($providerPeriodSlots as $timeSlot => $data) { $time = sprintf('%02d', floor($timeSlot / 3600)) . ':' . sprintf('%02d', floor(($timeSlot / 60) % 60)); $availableResult[$dateKey][$time] = $data; } } foreach ($provider['slots'] as $appointmentTime => $appointmentData) { $startInSeconds = $this->intervalService->getSeconds($appointmentTime . ':00'); if ($currentDateString === $dateKey && ($currentTimeStringInSeconds > $startInSeconds || $startTimeInSeconds > $startInSeconds) ) { continue; } $endInSeconds = $this->intervalService->getSeconds($appointmentData['endTime']); $newEndInSeconds = $startInSeconds + $realRequiredTime; if ($newEndInSeconds > $endInSeconds) { if ($dateKey !== $appointmentData['endDate']) { $nextDateString = DateTimeService::getDateTimeObjectInTimeZone( $dateKey . ' 00:00:00', $timeZone )->modify('+1 days')->format('Y-m-d'); if (!isset($freeIntervals[$nextDateString][$providerKey]['intervals'][0]) || $freeIntervals[$nextDateString][$providerKey]['intervals'][0][0] != $endInSeconds || $freeIntervals[$nextDateString][$providerKey]['intervals'][0][1] < $newEndInSeconds - 86400 ) { continue; } } elseif ($newEndInSeconds > 86400) { $nextIntervalIsValid = false; foreach ($freeIntervals[$dateKey][$providerKey]['intervals'] as $interval) { if ($interval[0] === $endInSeconds && $interval[1] === 86400) { $nextIntervalIsValid = true; break; } } if (!$nextIntervalIsValid) { continue; } $nextDateString = DateTimeService::getDateTimeObjectInTimeZone( $dateKey . ' 00:00:00', $timeZone )->modify('+1 days')->format('Y-m-d'); if (!isset($freeIntervals[$nextDateString][$providerKey]['intervals'][0]) || $freeIntervals[$nextDateString][$providerKey]['intervals'][0][0] != 0 || $freeIntervals[$nextDateString][$providerKey]['intervals'][0][1] < $newEndInSeconds - 86400 ) { continue; } } else { $nextIntervalIsValid = false; foreach ($freeIntervals[$dateKey][$providerKey]['intervals'] as $interval) { if ($interval[0] === $endInSeconds && $interval[1] >= $newEndInSeconds) { $nextIntervalIsValid = true; break; } } if (!$nextIntervalIsValid) { continue; } } } $availableResult[$dateKey][$appointmentTime][] = [ $providerKey, $appointmentData['locationId'], $appointmentData['places'], $appointmentData['serviceId'] ]; } foreach ($provider['full'] as $appointmentTime => $appointmentData) { $occupiedResult[$dateKey][$appointmentTime][] = [ $providerKey, $appointmentData['locationId'], $appointmentData['places'], $appointmentData['serviceId'] ]; } } } return [ 'available' => $availableResult, 'occupied' => $occupiedResult, ]; } /** * @param array $slots * @param string $timeZone * * @return array * @throws Exception */ private function getSlotsInMainTimeZoneFromTimeZone($slots, $timeZone) { $convertedProviderSlots = []; foreach ($slots as $slotDate => $slotTimes) { foreach ($slots[$slotDate] as $slotTime => $slotTimesProviders) { $convertedSlotParts = explode( ' ', DateTimeService::getDateTimeObjectInTimeZone( $slotDate . ' ' . $slotTime, $timeZone )->setTimezone(new DateTimeZone(DateTimeService::getTimeZone()->getName()))->format('Y-m-d H:i') ); $convertedProviderSlots[$convertedSlotParts[0]][$convertedSlotParts[1]] = $slotTimesProviders; } } return $convertedProviderSlots; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param array $settings * @param array $props * @param SlotsEntities $slotsEntities * @param Collection $appointments * * @return array * @throws Exception */ public function getSlots($settings, $props, $slotsEntities, $appointments) { $resourcedLocationsIntervals = $slotsEntities->getResources()->length() ? $this->resourceService->manageResources( $slotsEntities->getResources(), $appointments, $slotsEntities->getLocations(), $slotsEntities->getServices()->getItem($props['serviceId']), $slotsEntities->getProviders(), $props['locationId'], $props['excludeAppointmentId'], array_key_exists('totalPersons', $props) ? $props['totalPersons'] : $props['personsCount'] ) : []; $this->entityService->filterSlotsAppointments($slotsEntities, $appointments, $props); $this->providerService->addAppointmentsToAppointmentList( $slotsEntities->getProviders(), $appointments, $settings['isGloballyBusySlot'] ); return $this->getCalculatedFreeSlots( $settings, $props, $slotsEntities, $resourcedLocationsIntervals ); } /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param array $settings * @param array $props * @param SlotsEntities $slotsEntities * @param array $resourcedLocationsIntervals * * @return array * @throws Exception */ private function getCalculatedFreeSlots( $settings, $props, $slotsEntities, $resourcedLocationsIntervals ) { $freeProvidersSlots = []; /** @var DateTime $startDateTime */ $startDateTime = $props['startDateTime']; /** @var DateTime $endDateTime */ $endDateTime = $props['endDateTime']; /** @var Service $service */ $service = $slotsEntities->getServices()->getItem($props['serviceId']); /** @var Collection $providers */ $providers = $slotsEntities->getProviders(); /** @var Collection $locations */ $locations = $slotsEntities->getLocations(); $requiredTime = $this->entityService->getAppointmentRequiredTime( $service, $props['extras'] ); /** @var Provider $provider */ foreach ($providers->getItems() as $provider) { $providerContainer = new Collection(); if ($provider->getTimeZone()) { $this->providerService->modifyProviderTimeZone( $provider, $settings['globalDaysOff'], $startDateTime, $endDateTime ); } $start = $provider->getTimeZone() ? DateTimeService::getCustomDateTimeObjectInTimeZone( $startDateTime->format('Y-m-d H:i'), $provider->getTimeZone()->getValue() ) : DateTimeService::getCustomDateTimeObject($startDateTime->format('Y-m-d H:i')); $end = $provider->getTimeZone() ? DateTimeService::getCustomDateTimeObjectInTimeZone( $endDateTime->format('Y-m-d H:i'), $provider->getTimeZone()->getValue() ) : DateTimeService::getCustomDateTimeObject($endDateTime->format('Y-m-d H:i')); $providerContainer->addItem($provider, $provider->getId()->getValue()); $freeIntervals = $this->getFreeTime( $service, $props['locationId'], $locations, $providerContainer, $settings['allowAdminBookAtAnyTime'] || $provider->getTimeZone() ? [] : $settings['globalDaysOff'], $start, $end, $props['personsCount'], $settings['allowBookingIfPending'], $settings['allowBookingIfNotMin'], $props['isFrontEndBooking'] ? $settings['openedBookingAfterMin'] : false ); $freeProvidersSlots[$provider->getId()->getValue()] = $this->getAppointmentFreeSlots( $service, $requiredTime, $freeIntervals, !empty($resourcedLocationsIntervals[$provider->getId()->getValue()]) ? $resourcedLocationsIntervals[$provider->getId()->getValue()] : [], $settings['timeSlotLength'] ?: $requiredTime, $start, $settings['serviceDurationAsSlot'], $settings['bufferTimeInSlot'], true, $provider->getTimeZone() ? $provider->getTimeZone()->getValue() : DateTimeService::getTimeZone()->getName() ); } $freeSlots = [ 'available' => [], 'occupied' => [], ]; foreach ($freeProvidersSlots as $providerKey => $providerSlots) { /** @var Provider $provider */ $provider = $providers->getItem($providerKey); foreach (['available', 'occupied'] as $type) { if ($provider->getTimeZone()) { $providerSlots[$type] = $this->getSlotsInMainTimeZoneFromTimeZone( $providerSlots[$type], $provider->getTimeZone()->getValue() ); } foreach ($providerSlots[$type] as $dateKey => $dateSlots) { foreach ($dateSlots as $timeKey => $slotData) { if (empty($freeSlots[$type][$dateKey][$timeKey])) { $freeSlots[$type][$dateKey][$timeKey] = []; } foreach ($slotData as $item) { $freeSlots[$type][$dateKey][$timeKey][] = $item; } if (isset($freeSlots[$type][$dateKey])) { if (!$freeSlots[$type][$dateKey]) { unset($freeSlots[$type][$dateKey]); } else { ksort($freeSlots[$type][$dateKey]); } } } } } } return $freeSlots; } } Services/Settings/SettingsService.php 0000666 00000011747 15165375612 0014012 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Settings; use AmeliaBooking\Domain\Entity\Settings\Settings; use AmeliaBooking\Domain\Factory\Settings\SettingsFactory; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class SettingsService * * @package AmeliaBooking\Domain\Services\Settings */ class SettingsService { const NUMBER_OF_DAYS_AVAILABLE_FOR_BOOKING = 365; /** @var SettingsStorageInterface */ private $settingsStorage; /** * SettingsService constructor. * * @param SettingsStorageInterface $settingsStorage */ public function __construct(SettingsStorageInterface $settingsStorage) { $this->settingsStorage = $settingsStorage; } /** * @param $settingCategoryKey * @param $settingKey * @param null $defaultValue * * @return mixed|null */ public function getSetting($settingCategoryKey, $settingKey, $defaultValue = null) { if (null !== $this->settingsStorage->getSetting($settingCategoryKey, $settingKey)) { return $this->settingsStorage->getSetting($settingCategoryKey, $settingKey); } return $defaultValue; } /** * @param $settingCategoryKey * * @return mixed|array */ public function getCategorySettings($settingCategoryKey) { return $this->settingsStorage->getCategorySettings($settingCategoryKey); } /** * Return array of all settings where keys are settings names and values are settings values * * @return mixed */ public function getAllSettings() { return $this->settingsStorage->getAllSettings(); } /** * Return array of arrays where keys are settings categories names and values are categories settings * * @return mixed */ public function getAllSettingsCategorized() { return $this->settingsStorage->getAllSettingsCategorized(); } /** * @return mixed */ public function getFrontendSettings() { return $this->settingsStorage->getFrontendSettings(); } /** * @param $settingCategoryKey * @param $settingKey * @param $settingValue * * @return mixed */ public function setSetting($settingCategoryKey, $settingKey, $settingValue) { return $this->settingsStorage->setSetting($settingCategoryKey, $settingKey, $settingValue); } /** * @param $settingCategoryKey * @param $settingValues * * @return mixed */ public function setCategorySettings($settingCategoryKey, $settingValues) { return $this->settingsStorage->setCategorySettings($settingCategoryKey, $settingValues); } /** * @param $settings * * @return mixed */ public function setAllSettings($settings) { return $this->settingsStorage->setAllSettings($settings); } /** * @param Json $entitySettingsJson * * @return Settings */ public function getEntitySettings($entitySettingsJson) { return SettingsFactory::create($entitySettingsJson, $this->getAllSettingsCategorized()); } /** * @param Json $entitySettingsJson * * @return Settings */ public function getSavedSettings($entitySettingsJson) { $data = $entitySettingsJson ? json_decode($entitySettingsJson->getValue(), true) : []; $isOldEntitySettings = !isset($data['activation']['version']); if ($isOldEntitySettings && isset($data['general']['minimumTimeRequirementPriorToCanceling'])) { $data['general']['minimumTimeRequirementPriorToRescheduling'] = $data['general']['minimumTimeRequirementPriorToCanceling']; } return $data; } /** * @param array $entities * * @return void */ public function setStashEntities($entities) { update_option('amelia_stash', json_encode($entities)); } /** * @return array */ public function getStashEntities() { $entitiesStash = get_option('amelia_stash'); return $entitiesStash ? json_decode($entitiesStash, true) : []; } /** * @param array $settings * * @return void */ public function fixCustomization(&$settings) { if (isset($settings['forms']) && $settings['forms']) { foreach ($settings['forms'] as $formName => &$form) { if (isset($form['confirmBookingForm'])) { foreach ($form['confirmBookingForm'] as $entityName => &$entity) { if (isset($entity['itemsStatic']['paymentMethodFormField']['switchPaymentMethodViewOptions'])) { array_splice( $settings['forms'][$formName]['confirmBookingForm'][$entityName]['itemsStatic']['paymentMethodFormField']['switchPaymentMethodViewOptions'], 2 ); } } } } } } } Services/Settings/SettingsStorageInterface.php 0000666 00000002362 15165375612 0015630 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Settings; /** * Interface SettingsStorageInterface * * @package AmeliaBooking\Domain\Services\Settings */ interface SettingsStorageInterface { /** * @param $settingCategoryKey * @param $settingKey * * @return mixed */ public function getSetting($settingCategoryKey, $settingKey); /** * @param $settingCategoryKey * * @return mixed */ public function getCategorySettings($settingCategoryKey); /** * @return mixed */ public function getAllSettings(); /** * @return mixed */ public function getAllSettingsCategorized(); /** * @return mixed */ public function getFrontendSettings(); /** * @param $settingCategoryKey * @param $settingKey * @param $settingValue * * @return mixed */ public function setSetting($settingCategoryKey, $settingKey, $settingValue); /** * @param $settingCategoryKey * @param $settingValue * * @return mixed */ public function setCategorySettings($settingCategoryKey, $settingValue); /** * @param $settings * * @return mixed */ public function setAllSettings($settings); } Services/Schedule/ScheduleService.php 0000666 00000021605 15165375612 0013674 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\Entity\Schedule\Period; use AmeliaBooking\Domain\Entity\Schedule\PeriodService; use AmeliaBooking\Domain\Entity\Schedule\SpecialDay; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriod; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriodService; use AmeliaBooking\Domain\Entity\Schedule\TimeOut; use AmeliaBooking\Domain\Entity\Schedule\WeekDay; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Services\Interval\IntervalService; use AmeliaBooking\Domain\Services\Location\LocationService; use AmeliaBooking\Domain\Services\User\ProviderService; use DateTime; use DateInterval; use DatePeriod; use Exception; /** * Class ScheduleService * * @package AmeliaBooking\Domain\Services\Schedule */ class ScheduleService { /** @var IntervalService */ private $intervalService; /** @var ProviderService */ private $providerService; /** @var ProviderService */ private $locationService; /** * ScheduleService constructor. * * @param IntervalService $intervalService * @param ProviderService $providerService * @param LocationService $locationService */ public function __construct( $intervalService, $providerService, $locationService ) { $this->intervalService = $intervalService; $this->providerService = $providerService; $this->locationService = $locationService; } /** @noinspection MoreThanThreeArgumentsInspection */ /** * get special dates intervals for provider. * * @param Provider $provider * @param Collection $locations * @param int|null $locationId * @param int $serviceId * * @return array * @throws Exception * @throws InvalidArgumentException */ public function getProviderSpecialDayIntervals($provider, $locations, $locationId, $serviceId) { $intervals = []; $hasVisibleLocations = $this->locationService->hasVisibleLocations($locations); /** @var Location $providerLocation */ $providerLocation = $provider->getLocationId() && $locations->length() && $locations->keyExists($provider->getLocationId()->getValue()) ? $locations->getItem($provider->getLocationId()->getValue()) : null; /** @var SpecialDay $specialDay */ foreach ($provider->getSpecialDayList()->getItems() as $specialDay) { $specialDates = []; $endDateCopy = clone $specialDay->getEndDate()->getValue(); $specialDaysPeriod = new DatePeriod( $specialDay->getStartDate()->getValue(), new DateInterval('P1D'), $endDateCopy->modify('+1 day') ); /** @var DateTime $day */ foreach ($specialDaysPeriod as $day) { $specialDates[$day->format('Y-m-d')] = true; } $specialDatesIntervals = []; /** @var SpecialDayPeriod $period */ foreach ($specialDay->getPeriodList()->getItems() as $period) { /** @var Collection $availablePeriodLocations */ $availablePeriodLocations = $this->providerService->getProviderPeriodLocations( $period, $providerLocation, $locations, $hasVisibleLocations ); if (($hasVisibleLocations && !$availablePeriodLocations->length()) || ($hasVisibleLocations && $locationId && !$availablePeriodLocations->keyExists($locationId)) ) { continue; } $hasService = $period->getPeriodServiceList()->length() === 0; /** @var SpecialDayPeriodService $periodService */ foreach ($period->getPeriodServiceList()->getItems() as $periodService) { if ($periodService->getServiceId()->getValue() === $serviceId) { $hasService = true; } } $start = $this->intervalService->getSeconds($period->getStartTime()->getValue()->format('H:i:s')); $end = $this->intervalService->getSeconds($this->intervalService->getEndTimeString($period->getEndTime()->getValue()->format('H:i:s'))); if ($hasService) { $specialDatesIntervals['free'][$start] = [ $start, $end, $locationId ? [$locationId] : $availablePeriodLocations->keys(), ]; } } $intervals[] = [ 'dates' => $specialDates, 'intervals' => $specialDatesIntervals ]; } return array_reverse($intervals); } /** @noinspection MoreThanThreeArgumentsInspection */ /** * get week days intervals for provider. * * @param Provider $provider * @param Collection $locations * @param int $serviceId * @param int|null $locationId * * @return array * @throws InvalidArgumentException */ public function getProviderWeekDaysIntervals($provider, $locations, $locationId, $serviceId) { $intervals = []; $hasVisibleLocations = $this->locationService->hasVisibleLocations($locations); /** @var Location $providerLocation */ $providerLocation = $provider->getLocationId() && $locations->length() ? $locations->getItem($provider->getLocationId()->getValue()) : null; $providerLocationId = $providerLocation ? $providerLocation->getId()->getValue() : null; /** @var WeekDay $weekDay */ foreach ($provider->getWeekDayList()->getItems() as $weekDay) { $dayIndex = $weekDay->getDayIndex()->getValue(); $intervals[$dayIndex]['busy'] = []; $intervals[$dayIndex]['free'] = []; /** @var TimeOut $timeOut */ foreach ($weekDay->getTimeOutList()->getItems() as $timeOut) { $start = $this->intervalService->getSeconds($timeOut->getStartTime()->getValue()->format('H:i:s')); $intervals[$dayIndex]['busy'][$start] = [ $start, $this->intervalService->getSeconds($timeOut->getEndTime()->getValue()->format('H:i:s')) ]; } /** @var Period $period */ foreach ($weekDay->getPeriodList()->getItems() as $period) { /** @var Collection $availablePeriodLocations */ $availablePeriodLocations = $this->providerService->getProviderPeriodLocations( $period, $providerLocation, $locations, $hasVisibleLocations ); if (($hasVisibleLocations && !$availablePeriodLocations->length()) || ($hasVisibleLocations && $locationId && !$availablePeriodLocations->keyExists($locationId)) ) { continue; } $hasService = $period->getPeriodServiceList()->length() === 0; /** @var PeriodService $periodService */ foreach ($period->getPeriodServiceList()->getItems() as $periodService) { if ($periodService->getServiceId()->getValue() === $serviceId) { $hasService = true; } } $start = $this->intervalService->getSeconds($period->getStartTime()->getValue()->format('H:i:s')); $end = $this->intervalService->getSeconds($this->intervalService->getEndTimeString($period->getEndTime()->getValue()->format('H:i:s'))); if ($hasService) { $intervals[$dayIndex]['free'][$start] = [ $start, $end, $locationId ? [$locationId] : $availablePeriodLocations->keys(), ]; } } if ($weekDay->getPeriodList()->length() === 0) { $start = $this->intervalService->getSeconds($weekDay->getStartTime()->getValue()->format('H:i:s')); $end = $this->intervalService->getSeconds($this->intervalService->getEndTimeString($weekDay->getEndTime()->getValue()->format('H:i:s'))); $intervals[$dayIndex]['free'][$start] = [$start, $end, [$providerLocationId]]; } $intervals[$dayIndex]['free'] = $this->intervalService->getAvailableIntervals( $intervals[$dayIndex]['free'], isset($intervals[$dayIndex]['busy']) ? $intervals[$dayIndex]['busy'] : [] ); } return $intervals; } } Services/Payment/PaymentServiceInterface.php 0000666 00000001351 15165375612 0015253 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Payment; /** * Interface PaymentServiceInterface * * @package AmeliaBooking\Domain\Services\Payment */ interface PaymentServiceInterface { /** * @param array $data * * @return mixed */ public function execute($data); /** * @param array $data * * @return array */ public function getPaymentLink($data); /** * @param array $data * * @return array */ public function refund($data); /** * @param string $id * * @return mixed */ public function getTransactionAmount($id); } Services/Payment/AbstractPaymentService.php 0000666 00000001262 15165375612 0015117 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Payment; use AmeliaBooking\Domain\Services\Settings\SettingsService; /** * Class AbstractPaymentService * * @package AmeliaBooking\Domain\Services\Payment */ class AbstractPaymentService { /** * @var SettingsService $settingsService */ protected $settingsService; /** * PayPalService constructor. * * @param SettingsService $settingsService */ public function __construct( SettingsService $settingsService ) { $this->settingsService = $settingsService; } } Services/Resource/AbstractResourceService.php 0000666 00000004022 15165375612 0015440 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Resource; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; /** * Class AbstractResourceService * * @package AmeliaBooking\Domain\Services\Resource */ abstract class AbstractResourceService { /** * set substitute resources instead of resources that are not shred between services/locations * * @param Collection $resources * @param array $entitiesIds * * @return void * @throws InvalidArgumentException */ abstract public function setNonSharedResources($resources, $entitiesIds); /** * get collection of resources for service * * @param Collection $resources * @param int $serviceId * * @return Collection * @throws InvalidArgumentException */ abstract public function getServiceResources($resources, $serviceId); /** * get providers id values for resources * * @param Collection $resources * * @return array */ abstract public function getResourcesProvidersIds($resources); /** @noinspection MoreThanThreeArgumentsInspection */ /** * set unavailable intervals (fake appointments) to providers in moments when resources are used up * return intervals of resources with locations that are used up * * @param Collection $resources * @param Collection $appointments * @param Collection $allLocations * @param Service $service * @param Collection $providers * @param int|null $locationId * @param int|null $excludeAppointmentId * @param int $personsCount * * @return array * @throws InvalidArgumentException */ abstract public function manageResources( $resources, $appointments, $allLocations, $service, $providers, $locationId, $excludeAppointmentId, $personsCount ); } Services/Resource/BasicResourceService.php 0000666 00000004047 15165375612 0014725 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Resource; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; /** * Class BasicResourceService * * @package AmeliaBooking\Domain\Services\Resource */ class BasicResourceService extends AbstractResourceService { /** * set substitute resources instead of resources that are not shred between services/locations * * @param Collection $resources * @param array $entitiesIds * * @return void * @throws InvalidArgumentException */ public function setNonSharedResources($resources, $entitiesIds) { } /** * get collection of resources for service * * @param Collection $resources * @param int $serviceId * * @return Collection * @throws InvalidArgumentException */ public function getServiceResources($resources, $serviceId) { return new Collection(); } /** * get providers id values for resources * * @param Collection $resources * * @return array */ public function getResourcesProvidersIds($resources) { return []; } /** * set unavailable intervals (fake appointments) to providers in moments when resources are used up * return intervals of resources with locations that are used up * * @param Collection $resources * @param Collection $appointments * @param Collection $allLocations * @param Service $service * @param Collection $providers * @param int|null $locationId * @param int|null $excludeAppointmentId * @param int $personsCount * * @return array * @throws InvalidArgumentException */ public function manageResources( $resources, $appointments, $allLocations, $service, $providers, $locationId, $excludeAppointmentId, $personsCount ) { return []; } } Services/Notification/MailServiceInterface.php 0000666 00000001132 15165375612 0015526 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Notification; /** * Interface MailServiceInterface * * @package AmeliaBooking\Domain\Services\Notification */ interface MailServiceInterface { /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param $to * @param $subject * @param $body * @param bool $bcc * * @return mixed * @SuppressWarnings(PHPMD) */ public function send($to, $subject, $body, $bcc = false); } Services/Notification/AbstractMailService.php 0000666 00000001161 15165375612 0015373 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Notification; /** * Class AbstractMailService * * @package AmeliaBooking\Domain\Services\Notification */ class AbstractMailService { /** @var string */ protected $from; /** @var string */ protected $fromName; /** * AbstractMailService constructor. * * @param $from * @param $fromName */ public function __construct($from, $fromName) { $this->from = $from; $this->fromName = $fromName; } } Services/Notification/SMSAPIServiceInterface.php 0000666 00000005760 15165375612 0015653 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Notification; /** * Interface SMSAPIServiceInterface * * @package AmeliaBooking\Domain\Services\Notification */ interface SMSAPIServiceInterface { /** * @param $route * @param $authorize * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function sendRequest($route, $authorize, $data = null); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function signUp($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function signIn($data); /** * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function getUserInfo(); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function forgotPassword($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function resetPassword($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function changePassword($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function getCountryPriceList($data); /** * @param $data * * @return mixed * * @throws \AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException * @throws \AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException * @throws \Interop\Container\Exception\ContainerException */ public function testNotification($data); /** * @param $to * @param $body * @param $callbackUrl * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function send($to, $body, $callbackUrl); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function refreshSMSHistory($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function paymentCheckout($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function paymentComplete($data); /** * @param $data * * @return mixed * * @throws \Interop\Container\Exception\ContainerException */ public function getPaymentHistory($data); } Services/DateTime/DateTimeService.php 0000666 00000015247 15165375612 0013601 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\DateTime; /** * Class DateTimeService * * @package AmeliaBooking\Domain\Services\DateTime */ class DateTimeService { /** @var \DateTimeZone */ private static $timeZone; /** * @param array $settings */ public static function setTimeZone($settings) { if (!self::$timeZone) { if ($settings['timeZoneString']) { self::$timeZone = new \DateTimeZone($settings['timeZoneString']); } elseif ($settings['gmtOffset']) { $hours = (int)$settings['gmtOffset']; $minutes = ($settings['gmtOffset'] - floor($settings['gmtOffset'])) * 60; self::$timeZone = new \DateTimeZone(sprintf('%+03d:%02d', $hours, $minutes)); } else { self::$timeZone = new \DateTimeZone('UTC'); } } } /** * @return \DateTimeZone */ public static function getTimeZone() { return self::$timeZone; } /** * Return now date and time object by timezone settings * * @return \DateTime */ public static function getNowDateTimeObject() { return new \DateTime('now', self::getTimeZone()); } /** * Return now date and time string by timezone settings * * @return string */ public static function getNowDateTime() { return self::getNowDateTimeObject()->format('Y-m-d H:i:s'); } /** * @param String $dateTimeString * * @return \DateTime */ public static function getCustomDateTimeObject($dateTimeString) { return new \DateTime($dateTimeString ? $dateTimeString : 'now', self::getTimeZone()); } /** * Return custom date and time string by timezone settings * * @param String $dateTimeString * * @return string */ public static function getCustomDateTime($dateTimeString) { return self::getCustomDateTimeObject($dateTimeString)->format('Y-m-d H:i:s'); } /** * @param String $dateTimeString * @param int $clientUtcOffset * * @return \DateTime */ public static function getClientUtcCustomDateTimeObject($dateTimeString, $clientUtcOffset) { $clientDateTime = new \DateTime($dateTimeString, new \DateTimeZone('UTC')); if ($clientUtcOffset > 0) { $clientDateTime->modify("+{$clientUtcOffset} minutes"); } elseif ($clientUtcOffset < 0) { $clientDateTime->modify("{$clientUtcOffset} minutes"); } return $clientDateTime; } /** * Return custom date and time string by utc offset * * @param String $dateTimeString * @param int $clientUtcOffset * * @return string */ public static function getClientUtcCustomDateTime($dateTimeString, $clientUtcOffset) { return self::getClientUtcCustomDateTimeObject($dateTimeString, $clientUtcOffset)->format('Y-m-d H:i:s'); } /** * Return now date and time object in UTC * * @return \DateTime */ public static function getNowDateTimeObjectInUtc() { return self::getNowDateTimeObject()->setTimezone(new \DateTimeZone('UTC')); } /** * Return now date and time string in UTC * * @return string */ public static function getNowDateTimeInUtc() { return self::getNowDateTimeObjectInUtc()->format('Y-m-d H:i:s'); } /** * Return custom date and time object in UTC * * @param $dateTimeString * * @return \DateTime */ public static function getCustomDateTimeObjectInUtc($dateTimeString) { return self::getCustomDateTimeObject($dateTimeString)->setTimezone(new \DateTimeZone('UTC')); } /** * Return custom date and time object in UTC * * @param $dateTimeString * @param $timezone * * @return \DateTime */ public static function getCustomDateTimeObjectInTimeZone($dateTimeString, $timezone) { return self::getCustomDateTimeObject($dateTimeString)->setTimezone(new \DateTimeZone($timezone)); } /** * Return custom date and time object in UTC * * @param $dateTimeString * @param $timezone * * @return \DateTime */ public static function getDateTimeObjectInTimeZone($dateTimeString, $timezone) { return (new \DateTime($dateTimeString, new \DateTimeZone($timezone))); } /** * Return custom date and time string in UTC * * @param $dateTimeString * * @return string */ public static function getCustomDateTimeInUtc($dateTimeString) { return self::getCustomDateTimeObjectInUtc($dateTimeString)->format('Y-m-d H:i:s'); } /** * Return custom date and time object from UTC * * @param $dateTimeString * * @return \DateTime */ public static function getCustomDateTimeObjectFromUtc($dateTimeString) { return (new \DateTime($dateTimeString, new \DateTimeZone('UTC')))->setTimezone(self::getTimeZone()); } /** * Return custom date and time string from UTC * * @param $dateTimeString * * @return string */ public static function getCustomDateTimeFromUtc($dateTimeString) { return self::getCustomDateTimeObjectFromUtc($dateTimeString)->format('Y-m-d H:i:s'); } /** * Return custom date and time RFC3339 from UTC * * @param string $dateTimeString * * @return string */ public static function getCustomDateTimeRFC3339($dateTimeString) { return self::getCustomDateTimeObjectInUtc($dateTimeString)->format(DATE_RFC3339); } /** * Return now date string by timezone settings * * @return string */ public static function getNowDate() { return self::getNowDateTimeObject()->format('Y-m-d'); } /** * Return now time string by timezone settings * * @return string */ public static function getNowTime() { return self::getNowDateTimeObject()->format('H:i:s'); } /** * Return current Unix timestamp * * @return false|int */ public static function getNowTimestamp() { return strtotime(self::getNowTime()); } /** * Return Day Index for passed date string in 'YYYY-MM-DD' format. * Monday index is 1, Sunday index is 7. * * @param $dateString * * @return int */ public static function getDayIndex($dateString) { return self::getCustomDateTimeObject($dateString)->format('N'); } } Services/Booking/AppointmentDomainService.php 0000666 00000015343 15165375612 0015424 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Booking; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; /** * Class AppointmentDomainService * * @package AmeliaBooking\Domain\Services\Booking */ class AppointmentDomainService { /** * Returns an array with bookings statuses count for passed appointment * * @param Appointment $appointment * * @return array * @throws InvalidArgumentException */ public function getBookingsStatusesCount($appointment) { $approvedBookings = 0; $pendingBookings = 0; $canceledBookings = 0; $rejectedBookings = 0; $noShowBookings = 0; foreach ((array)$appointment->getBookings()->keys() as $customerBookingKey) { /** @var CustomerBooking $booking */ $booking = $appointment->getBookings()->getItem($customerBookingKey); switch ($booking->getStatus()->getValue()) { case BookingStatus::PENDING: $pendingBookings += $booking->getPersons()->getValue(); break; case BookingStatus::CANCELED: $canceledBookings += $booking->getPersons()->getValue(); break; case BookingStatus::REJECTED: $rejectedBookings += $booking->getPersons()->getValue(); break; case BookingStatus::NO_SHOW: $noShowBookings += $booking->getPersons()->getValue(); break; default: $approvedBookings += $booking->getPersons()->getValue(); break; } } return [ 'approvedBookings' => $approvedBookings, 'pendingBookings' => $pendingBookings, 'canceledBookings' => $canceledBookings, 'rejectedBookings' => $rejectedBookings, 'noShowBookings' => $noShowBookings ]; } /** * @param Service $service * @param array $bookingsCount * * @return string */ public function getAppointmentStatusWhenEditAppointment($service, $bookingsCount) { $totalBookings = array_sum($bookingsCount); if ($bookingsCount['canceledBookings'] === $totalBookings) { return BookingStatus::CANCELED; } if ($bookingsCount['noShowBookings'] === $totalBookings) { return BookingStatus::NO_SHOW; } if ($bookingsCount['rejectedBookings'] === $totalBookings) { return BookingStatus::REJECTED; } if ($bookingsCount['approvedBookings'] === 0 && $bookingsCount['pendingBookings'] === 0) { return BookingStatus::CANCELED; } return $bookingsCount['approvedBookings'] >= $service->getMinCapacity()->getValue() ? BookingStatus::APPROVED : BookingStatus::PENDING; } /** * When booking status is changed, find out appointment status. * * If there is no any more 'approved' and 'pending' bookings, set appointment status to 'canceled' or 'rejected'. * * If appointment status is 'approved' or 'pending' and minimum capacity condition is not satisfied, * set appointment status to 'pending'. * * @param Service $service * @param array $bookingsCount * @param string $requestedStatus * * @return string */ public function getAppointmentStatusWhenChangingBookingStatus($service, $bookingsCount, $requestedStatus) { if ($bookingsCount['approvedBookings'] === 0 && $bookingsCount['pendingBookings'] === 0) { return $requestedStatus; } return $bookingsCount['approvedBookings'] >= $service->getMinCapacity()->getValue() ? BookingStatus::APPROVED : BookingStatus::PENDING; } /** * sort and merge appointments by date-time * * @param Collection $appointments * * @return Collection * @throws InvalidArgumentException */ public function getSortedAndMergedAppointments($appointments) { $timeStampsData = []; /** @var Appointment $appointment */ foreach ($appointments->getItems() as $index => $appointment) { $timeStampStart = $appointment->getBookingStart()->getValue()->getTimestamp(); $timeStampEnd = $appointment->getBookingEnd()->getValue()->getTimestamp(); if (!isset($timeStampsData[$timeStampStart])) { $timeStampsData[$timeStampStart] = [$timeStampEnd, $index]; } else { /** @var Appointment $passedAppointment */ $passedAppointment = $appointments->getItem($timeStampsData[$timeStampStart][1]); if ($appointment->getBookingEnd()->getValue() > $passedAppointment->getBookingEnd()->getValue()) { $timeStampsData[$timeStampStart] = [$timeStampEnd, $index]; } } } ksort($timeStampsData); $mergedTimeStampsData = []; $previousInterval = null; foreach ($timeStampsData as $start => $currentInterval) { if ($previousInterval !== null && $start <= $previousInterval[1]) { if ($currentInterval[0] > $previousInterval[1]) { $mergedTimeStampsData[$previousInterval[0]][0] = $currentInterval[0]; } } else { $mergedTimeStampsData[$start] = $currentInterval; $previousInterval = [ $start, $currentInterval[0], $currentInterval[1] ]; } } /** @var Collection $sortedAndMergedAppointments */ $sortedAndMergedAppointments = new Collection(); foreach ($mergedTimeStampsData as $start => $interval) { /** @var Appointment $appointment */ $appointment = $appointments->getItem($interval[1]); $appointment->setBookingStart( new DateTimeValue(DateTimeService::getNowDateTimeObject()->setTimestamp($start)) ); $appointment->setBookingEnd( new DateTimeValue(DateTimeService::getNowDateTimeObject()->setTimestamp($interval[0])) ); $sortedAndMergedAppointments->addItem($appointment); } return $sortedAndMergedAppointments; } } Services/Booking/EventDomainService.php 0000666 00000050717 15165375612 0014213 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Booking; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Booking\Event\Event; use AmeliaBooking\Domain\Entity\Booking\Event\EventPeriod; use AmeliaBooking\Domain\Entity\Booking\Event\EventTicket; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Factory\Booking\Event\EventTicketFactory; use AmeliaBooking\Domain\Factory\Gallery\GalleryImageFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\Services\Settings\SettingsService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\Recurring; use AmeliaBooking\Domain\ValueObjects\String\Cycle; /** * Class EventDomainService * * @package AmeliaBooking\Domain\Services\Booking */ class EventDomainService { /** * @param Recurring $recurring * @param Collection $eventPeriods * * @return Collection * * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public function getRecurringEventsPeriods($recurring, $eventPeriods) { $recurringPeriods = new Collection(); if (!($recurring && $recurring->getCycle() && $recurring->getUntil())) { return $recurringPeriods; } $dateNew = null; $modifyCycle = 'days'; $modifyBaseValue = $recurring->getCycleInterval()->getValue(); switch ($recurring->getCycle()->getValue()) { case (Cycle::DAILY): $modifyCycle = 'days'; break; case (Cycle::WEEKLY): $modifyCycle = 'days'; $modifyBaseValue = 7*$modifyBaseValue; break; case (Cycle::MONTHLY): if ($recurring->getMonthlyRepeat() === 'on') { $repeatPeriod = $recurring->getMonthlyOnRepeat() . ' ' . $recurring->getMonthlyOnDay(); } else { $dateNew = $recurring->getMonthDate(); } $modifyCycle = 'months'; break; case (Cycle::YEARLY): $modifyCycle = 'years'; break; } $hasMoreRecurringPeriods = true; $recurringOrder = 1; while ($hasMoreRecurringPeriods) { $periods = new Collection(); $modifyValue = $recurringOrder * $modifyBaseValue; $periodStartDate0 = DateTimeService::getCustomDateTimeObject($eventPeriods->getItem(0)->getPeriodStart()->getValue()->format('Y-m-d H:i:s')); $periodEndDate0 = DateTimeService::getCustomDateTimeObject($eventPeriods->getItem(0)->getPeriodEnd()->getValue()->format('Y-m-d H:i:s')); if (isset($repeatPeriod)) { $periodStart0 = $this->getNextPeriodStartDate($periodStartDate0, $modifyValue, $repeatPeriod); $dayDifference = $periodStartDate0->diff($periodStart0); } else if ($dateNew) { $periodStartNew = DateTimeService::getCustomDateTimeObject($dateNew->getValue()->format('Y-m-d H:i:s')); $dayDifference = $periodStartDate0->diff($periodStartNew); } for ($i = 0; $i < count($eventPeriods->getItems()); $i++) { $periodStartDate = DateTimeService::getCustomDateTimeObject($eventPeriods->getItem($i)->getPeriodStart()->getValue()->format('Y-m-d H:i:s')); $periodEndDate = DateTimeService::getCustomDateTimeObject($eventPeriods->getItem($i)->getPeriodEnd()->getValue()->format('Y-m-d H:i:s')); if (isset($repeatPeriod)) { if ($i === 0) { $periodStart = $periodStart0; $periodEnd = $periodEndDate0->add($dayDifference); } else { $periodStart = $periodStartDate->add($dayDifference); $periodEnd = $periodEndDate->add($dayDifference); } } else { $periodStart = $periodStartDate->modify("+{$modifyValue} {$modifyCycle}"); $periodEnd = $periodEndDate->modify("+{$modifyValue} {$modifyCycle}"); if ($dateNew) { $periodStart = $periodStart->add($dayDifference); $periodEnd = $periodEnd->add($dayDifference); } } $newEventPeriod = new EventPeriod(); $newEventPeriod->setPeriodStart(new DateTimeValue($periodStart)); $newEventPeriod->setPeriodEnd(new DateTimeValue($periodEnd)); $periods->addItem($newEventPeriod); if ($periodStart > $recurring->getUntil()->getValue()) { $hasMoreRecurringPeriods = false; } } if ($hasMoreRecurringPeriods) { $recurringPeriods->addItem($periods); $recurringOrder++; } } return $recurringPeriods; } /** * @param Collection $eventPeriods * @param bool $setId * * @return Collection * * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public function getClonedEventPeriods($eventPeriods, $setId = false) { $clonedPeriods = new Collection(); /** @var EventPeriod $eventPeriod **/ foreach ($eventPeriods->getItems() as $eventPeriod) { $periodStart = DateTimeService::getCustomDateTimeObject( $eventPeriod->getPeriodStart()->getValue()->format('Y-m-d H:i:s') ); $periodEnd = DateTimeService::getCustomDateTimeObject( $eventPeriod->getPeriodEnd()->getValue()->format('Y-m-d H:i:s') ); $newEventPeriod = new EventPeriod(); $newEventPeriod->setPeriodStart(new DateTimeValue($periodStart)); $newEventPeriod->setPeriodEnd(new DateTimeValue($periodEnd)); if ($eventPeriod->getZoomMeeting()) { $newEventPeriod->setZoomMeeting($eventPeriod->getZoomMeeting()); } if ($setId) { $newEventPeriod->setId(new Id($eventPeriod->getId()->getValue())); } $clonedPeriods->addItem($newEventPeriod); } return $clonedPeriods; } /** * @param Collection $eventTickets * * @return Collection * * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public function getClonedEventTickets($eventTickets) { $clonedTickets = new Collection(); /** @var EventTicket $eventTicket **/ foreach ($eventTickets->getItems() as $eventTicket) { $newEventTicket = EventTicketFactory::create($eventTicket->toArray()); $clonedTickets->addItem($newEventTicket); } return $clonedTickets; } /** * @param Event $followingEvent * @param Event $originEvent * @param Collection $clonedOriginEventPeriods * * @return void * * @throws \Slim\Exception\ContainerValueNotFoundException * @throws \Interop\Container\Exception\ContainerException * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public function buildFollowingEvent($followingEvent, $originEvent, $clonedOriginEventPeriods) { $followingEvent->setName($originEvent->getName()); $followingEvent->setPrice($originEvent->getPrice()); $followingEvent->setMaxCapacity($originEvent->getMaxCapacity()); $followingEvent->setTags($originEvent->getTags()); $followingEvent->setProviders($originEvent->getProviders()); $followingEvent->setBringingAnyone($originEvent->getBringingAnyone()); $followingEvent->setBookMultipleTimes($originEvent->getBookMultipleTimes()); $followingEvent->setOrganizerId($originEvent->getOrganizerId()); $followingEvent->setCustomPricing($originEvent->getCustomPricing()); $followingEvent->setCloseAfterMin($originEvent->getCloseAfterMin()); $followingEvent->setMaxCustomCapacity($originEvent->getMaxCustomCapacity()); $followingEvent->setCloseAfterMinBookings($originEvent->getCloseAfterMinBookings()); $followingEvent->setAggregatedPrice($originEvent->getAggregatedPrice()); $followingEvent->setMaxExtraPeople($originEvent->getMaxExtraPeople()); $followingEvent->setNotifyParticipants($originEvent->isNotifyParticipants()); if ($originEvent->getCustomPricing() && $originEvent->getCustomPricing()->getValue() && $followingEvent->getBookings()->length() === 0) { $newEventTickets = new Collection(); /** @var EventTicket $eventTicket */ foreach ($originEvent->getCustomTickets()->getItems() as $ticketIndex => $eventTicket) { if (!empty($followingEvent->getCustomTickets()->toArray()[$ticketIndex])) { $editedTicket = EventTicketFactory::create($followingEvent->getCustomTickets()->toArray()[$ticketIndex]); $editedTicket->setName($eventTicket->getName()); $editedTicket->setEnabled($eventTicket->getEnabled()); $editedTicket->setPrice($eventTicket->getPrice()); if ($eventTicket->getTranslations()) { $editedTicket->setTranslations($eventTicket->getTranslations()); } $editedTicket->setSpots($eventTicket->getSpots()); $newEventTickets->addItem($editedTicket); } else { $newTicket = EventTicketFactory::create($eventTicket->toArray()); $newTicket->setId(new Id(0)); $newTicket->setEventId($followingEvent->getId() ? new Id($followingEvent->getId()->getValue()) : null); $newTicket->setSold(new IntegerValue(0)); $newTicket->setDateRanges(new Json('[]')); $newEventTickets->addItem($newTicket); } } $followingEvent->setCustomTickets($newEventTickets); } if ($originEvent->getTranslations()) { $followingEvent->setTranslations($originEvent->getTranslations()); } if ($originEvent->getDeposit()) { $followingEvent->setDeposit($originEvent->getDeposit()); } if ($originEvent->getDepositPayment()) { $followingEvent->setDepositPayment($originEvent->getDepositPayment()); } if ($originEvent->getDepositPerPerson()) { $followingEvent->setDepositPerPerson($originEvent->getDepositPerPerson()); } $followingEventGallery = new Collection(); /** @var GalleryImage $image **/ foreach ($originEvent->getGallery()->getItems() as $image) { $followingEventGallery->addItem( GalleryImageFactory::create( [ 'id' => null, 'entityId' => $followingEvent->getId() ? $followingEvent->getId()->getValue() : null, 'entityType' => $image->getEntityType()->getValue(), 'pictureFullPath' => $image->getPicture()->getFullPath(), 'pictureThumbPath' => $image->getPicture()->getThumbPath(), 'position' => $image->getPosition()->getValue(), ] ) ); } $followingEvent->setGallery($followingEventGallery); if ($originEvent->getSettings()) { $followingEvent->setSettings($originEvent->getSettings()); } $followingEvent->setBookingOpens($originEvent->getBookingOpens()); $followingEvent->setBookingCloses($originEvent->getBookingCloses()); $followingEvent->setBookingOpensRec($originEvent->getBookingOpensRec()); $followingEvent->setBookingClosesRec($originEvent->getBookingClosesRec()); if ($originEvent->getLocationId()) { $followingEvent->setLocationId($originEvent->getLocationId()); } if ($originEvent->getCustomLocation()) { $followingEvent->setCustomLocation($originEvent->getCustomLocation()); } if ($originEvent->getTags()) { $followingEvent->setTags($originEvent->getTags()); } if ($originEvent->getDescription()) { $followingEvent->setDescription($originEvent->getDescription()); } if ($originEvent->getColor()) { $followingEvent->setColor($originEvent->getColor()); } if ($originEvent->getShow()) { $followingEvent->setShow($originEvent->getShow()); } if ($originEvent->getZoomUserId()) { $followingEvent->setZoomUserId($originEvent->getZoomUserId()); } $modifyCycle = 'days'; $modifyBaseValue = $originEvent->getRecurring()->getCycleInterval()->getValue(); $dateNew = null; switch ($originEvent->getRecurring()->getCycle()->getValue()) { case (Cycle::DAILY): $modifyCycle = 'days'; break; case (Cycle::WEEKLY): $modifyCycle = 'days'; $modifyBaseValue = 7*$modifyBaseValue; break; case (Cycle::MONTHLY): if ($followingEvent->getRecurring()->getMonthlyRepeat() === 'on') { $repeatPeriod = $followingEvent->getRecurring()->getMonthlyOnRepeat() . ' ' . $followingEvent->getRecurring()->getMonthlyOnDay(); } else { $dateNew = $followingEvent->getRecurring()->getMonthDate(); } $modifyCycle = 'months'; break; case (Cycle::YEARLY): $modifyCycle = 'years'; break; } $modifyValue = $modifyBaseValue * ($followingEvent->getRecurring()->getOrder()->getValue() - 1); $periodStartDate0 = DateTimeService::getCustomDateTimeObject($clonedOriginEventPeriods->getItem(0)->getPeriodStart()->getValue()->format('Y-m-d H:i:s')); $periodEndDate0 = DateTimeService::getCustomDateTimeObject($clonedOriginEventPeriods->getItem(0)->getPeriodEnd()->getValue()->format('Y-m-d H:i:s')); if (isset($repeatPeriod)) { $periodStart0 = $this->getNextPeriodStartDate($periodStartDate0, $modifyValue, $repeatPeriod); $dayDifference = $periodStartDate0->diff($periodStart0); } else if ($dateNew) { $thisPeriodStart = DateTimeService::getCustomDateTimeObject($originEvent->getPeriods()->getItem(0)->getPeriodStart()->getValue()->format('Y-m-d H:i:s')); $periodStartNew = DateTimeService::getCustomDateTimeObject($dateNew->getValue()->format('Y-m-d H:i:s')); $dayDifference = $thisPeriodStart->diff($periodStartNew); } /** @var EventPeriod $followingEventPeriod */ foreach ($followingEvent->getPeriods()->getItems() as $key => $followingEventPeriod) { if ($clonedOriginEventPeriods->keyExists($key)) { /** @var EventPeriod $clonedOriginEventPeriod */ $clonedOriginEventPeriod = $clonedOriginEventPeriods->getItem($key); $periodStartDate = DateTimeService::getCustomDateTimeObject($clonedOriginEventPeriod->getPeriodStart()->getValue()->format('Y-m-d H:i:s')); $periodEndDate = DateTimeService::getCustomDateTimeObject($clonedOriginEventPeriod->getPeriodEnd()->getValue()->format('Y-m-d H:i:s')); if (isset($repeatPeriod)) { if ($key === 0) { $periodStart = $periodStart0; $periodEnd = $periodEndDate0->add($dayDifference); } else { $periodStart = $periodStartDate->add($dayDifference); $periodEnd = $periodEndDate->add($dayDifference); } } else { $periodStart = $periodStartDate->modify("+{$modifyValue} {$modifyCycle}"); $periodEnd = $periodEndDate->modify("+{$modifyValue} {$modifyCycle}"); $toEndTime = $periodStart->diff($periodEnd); if ($dateNew) { $periodStart = DateTimeService::getCustomDateTimeObject($periodStart->format('Y-m-'. $periodStartNew->format('d') .' H:i:s')); $periodStartClone = clone $periodStart; $periodEnd = $periodStartClone->add($toEndTime); } } $followingEventPeriod->setPeriodStart(new DateTimeValue($periodStart)); $followingEventPeriod->setPeriodEnd(new DateTimeValue($periodEnd)); } else { $followingEvent->getPeriods()->deleteItem($key); } } /** @var EventPeriod $originEventPeriod */ foreach ($originEvent->getPeriods()->getItems() as $key => $originEventPeriod) { if (!$followingEvent->getPeriods()->keyExists($key)) { /** @var EventPeriod $followingEventPeriod */ $newFollowingEventPeriod = new EventPeriod(); $newPeriodStart = DateTimeService::getCustomDateTimeObject( $originEventPeriod->getPeriodStart()->getValue()->format('Y-m-d H:i:s') ); $newPeriodEnd = DateTimeService::getCustomDateTimeObject( $originEventPeriod->getPeriodEnd()->getValue()->format('Y-m-d H:i:s') ); if (isset($repeatPeriod)) { $periodStart = $newPeriodStart->add($dayDifference); $periodEnd = $newPeriodEnd->add($dayDifference); } else { $periodStart = $newPeriodStart->modify("+{$modifyValue} {$modifyCycle}"); $periodEnd = $newPeriodEnd->modify("+{$modifyValue} {$modifyCycle}"); $toEndTime = $periodStart->diff($periodEnd); if ($dateNew && $dayDifference && $dayDifference->format('%a') !== '0') { $periodStart = $periodStart->add($dayDifference); $periodStartClone = clone $periodStart; $periodEnd = $periodStartClone->add($toEndTime); } } $newFollowingEventPeriod->setPeriodStart(new DateTimeValue($periodStart)); $newFollowingEventPeriod->setPeriodEnd(new DateTimeValue($periodEnd)); $newFollowingEventPeriod->setEventId(new Id($followingEvent->getId()->getValue())); $followingEvent->getPeriods()->addItem($newFollowingEventPeriod); } } } /** * @param Collection $eventPeriods * @param bool $setId * * @return Collection * * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public function getShortcodeForEventList($container, $events) { /** @var SettingsService $settingsService */ $settingsService = $container->get('domain.settings.service'); $dateFormat = $settingsService->getSetting('wordpress', 'dateFormat'); for ($i=0; $i < count($events); $i++) { $dateString = explode(" ", $events[$i]['periods'][0]['periodStart'])[0]; $newDate = date_i18n($dateFormat, strtotime($dateString)); $events[$i]['formattedPeriodStart'] = $newDate; } return $events; } /** * @param \DateTime $periodStartDate0 * @param int $modifyValue * @param string $repeatPeriod * * @return \DateTime * * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException * @throws \Exception */ public function getNextPeriodStartDate($periodStartDate0, $modifyValue, $repeatPeriod) { $month = (int)$periodStartDate0->format('m') + $modifyValue; $year = (int)$periodStartDate0->format('Y'); $year += floor($month / 12); $month -= 12 * floor($month / 12); $time = (int)$periodStartDate0->format('H')*60 + (int)$periodStartDate0->format('i'); $periodStart0 = DateTimeService::getCustomDateTimeObject($repeatPeriod . " of $year-$month"); return $periodStart0->add(new \DateInterval('PT' . $time . 'M')); } } Services/Interval/IntervalService.php 0000666 00000011371 15165375612 0013753 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Interval; /** * Class IntervalService * * @package AmeliaBooking\Domain\Services\Interval */ class IntervalService { /** * @param string $time * * @return int */ public function getSeconds($time) { $timeParts = explode(':', $time); return $timeParts[0] * 60 * 60 + $timeParts[1] * 60 + $timeParts[2]; } /** * @param string $endTime * * @return string */ public function getEndTimeString($endTime) { return $endTime === '00:00:00' ? '24:00:00' : $endTime; } /** * get available appointment intervals. * * @param array $availableIntervals * @param array $unavailableIntervals * * @return array */ public function getAvailableIntervals(&$availableIntervals, $unavailableIntervals) { $parsedAvailablePeriod = []; ksort($availableIntervals); ksort($unavailableIntervals); foreach ($availableIntervals as $available) { $parsedAvailablePeriod[] = $available; foreach ($unavailableIntervals as $unavailable) { if ($parsedAvailablePeriod) { $lastAvailablePeriod = $parsedAvailablePeriod[sizeof($parsedAvailablePeriod) - 1]; if ($unavailable[0] >= $lastAvailablePeriod[0] && $unavailable[1] <= $lastAvailablePeriod[1]) { // unavailable interval is inside available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($fixedPeriod[0] !== $unavailable[0]) { $parsedAvailablePeriod[] = [$fixedPeriod[0], $unavailable[0], $fixedPeriod[2]]; } if ($unavailable[1] !== $fixedPeriod[1]) { $parsedAvailablePeriod[] = [$unavailable[1], $fixedPeriod[1], $fixedPeriod[2]]; } } elseif ($unavailable[0] <= $lastAvailablePeriod[0] && $unavailable[1] >= $lastAvailablePeriod[1]) { // available interval is inside unavailable interval array_pop($parsedAvailablePeriod); } elseif ($unavailable[0] <= $lastAvailablePeriod[0] && $unavailable[1] >= $lastAvailablePeriod[0] && $unavailable[1] <= $lastAvailablePeriod[1]) { // unavailable interval intersect start of available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($unavailable[1] !== $fixedPeriod[1]) { $parsedAvailablePeriod[] = [$unavailable[1], $fixedPeriod[1], $fixedPeriod[2]]; } } elseif ($unavailable[0] >= $lastAvailablePeriod[0] && $unavailable[0] <= $lastAvailablePeriod[1] && $unavailable[1] >= $lastAvailablePeriod[1]) { // unavailable interval intersect end of available interval $fixedPeriod = array_pop($parsedAvailablePeriod); if ($fixedPeriod[0] !== $unavailable[0]) { $parsedAvailablePeriod[] = [$fixedPeriod[0], $unavailable[0], $fixedPeriod[2]]; } } } } } return $parsedAvailablePeriod; } /** * @param array $data * @param int $startTime * @param int $endTime * * @return array */ public function getFreeIntervals($data, $startTime, $endTime) { $result = []; ksort($data); $firstIntervalTime = true; $lastStartTime = $startTime; foreach ((array)$data as &$interval) { // Appointment is out of working hours if ($interval[0] >= $endTime || $interval[1] <= $startTime) { continue; } // Beginning or End of the Appointment is out of working hours if ($interval[0] < $startTime && $interval[1] <= $endTime) { $interval[0] = $startTime; } elseif ($interval[0] >= $startTime && $interval[1] > $endTime) { $interval[1] = $endTime; } if ($lastStartTime !== $interval[0] && ($lastStartTime !== $startTime || ($firstIntervalTime && $lastStartTime !== $interval[0]))) { $firstIntervalTime = false; $result[$lastStartTime] = [ $lastStartTime, $interval[0] ]; } $lastStartTime = $interval[1]; } if ($lastStartTime !== $endTime) { $result[$lastStartTime] = [ $lastStartTime, $endTime ]; } return $result; } } Services/Location/CurrentLocationInterface.php 0000666 00000000654 15165375612 0015570 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Location; /** * Interface CurrentLocationInterface * * @package AmeliaBooking\Domain\Services\Location */ interface CurrentLocationInterface { /** * @return string * @SuppressWarnings(PHPMD) */ public function getCurrentLocationCountryIso(); } Services/Location/LocationService.php 0000666 00000001465 15165375612 0013726 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\Location; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\ValueObjects\String\Status; use Slim\Exception\ContainerValueNotFoundException; /** * Class LocationService * * @package AmeliaBooking\Domain\Services\Location */ class LocationService { /** * @param Collection $locations * * @return boolean * * @throws ContainerValueNotFoundException */ public function hasVisibleLocations($locations) { /** @var Location $location */ foreach ($locations->getItems() as $location) { if ($location->getStatus()->getValue() === Status::VISIBLE) { return true; } } return false; } } Services/Reservation/ReservationServiceInterface.php 0000666 00000021065 15165375612 0017027 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Services\Reservation; use AmeliaBooking\Application\Commands\CommandResult; use AmeliaBooking\Domain\Common\Exceptions\BookingCancellationException; use AmeliaBooking\Domain\Common\Exceptions\BookingsLimitReachedException; use AmeliaBooking\Domain\Common\Exceptions\BookingUnavailableException; use AmeliaBooking\Domain\Common\Exceptions\CouponExpiredException; use AmeliaBooking\Domain\Common\Exceptions\CouponInvalidException; use AmeliaBooking\Domain\Common\Exceptions\CouponUnknownException; use AmeliaBooking\Domain\Common\Exceptions\CustomerBookedException; use AmeliaBooking\Domain\Common\Exceptions\EventBookingUnavailableException; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Common\Exceptions\PackageBookingUnavailableException; use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Entity\Booking\Event\Event; use AmeliaBooking\Domain\Entity\Booking\Reservation; use AmeliaBooking\Domain\Entity\Payment\Payment; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException; use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException; use DateTime; use Exception; use Interop\Container\Exception\ContainerException; use Slim\Exception\ContainerValueNotFoundException; /** * Interface ReservationServiceInterface * * @package AmeliaBooking\Domain\Services\Reservation */ interface ReservationServiceInterface { /** * @param CustomerBooking $booking * @param string $requestedStatus * * @return array * * @throws ContainerValueNotFoundException * @throws InvalidArgumentException * @throws NotFoundException * @throws QueryExecutionException * @throws ContainerException * @throws NotFoundException * @throws BookingCancellationException */ public function updateStatus($booking, $requestedStatus); /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param int $bookingId * @param int $packageCustomerId * @param array $paymentData * @param float $amount * @param DateTime $dateTime * @param string $entityType * * @return Payment * * @throws ContainerValueNotFoundException * @throws InvalidArgumentException * @throws QueryExecutionException * @throws ContainerException */ public function addPayment($bookingId, $packageCustomerId, $paymentData, $amount, $dateTime, $entityType); /** * @param array $data * @param Reservation $reservation * @param bool $save * * @return CommandResult * * @throws ContainerValueNotFoundException * @throws InvalidArgumentException * @throws QueryExecutionException * @throws ContainerException * @throws Exception */ public function processRequest($data, $reservation, $save); /** * @param CommandResult $result * * @return void * @throws ContainerException * @throws InvalidArgumentException * @throws QueryExecutionException * @throws NotFoundException */ public function runPostBookingActions($result); /** * @param array $appointmentData * @param Reservation $reservation * @param bool $save * * @return void * * @throws BookingUnavailableException * @throws BookingsLimitReachedException * @throws CustomerBookedException * @throws PackageBookingUnavailableException * @throws EventBookingUnavailableException * @throws CouponExpiredException * @throws CouponInvalidException * @throws CouponUnknownException * @throws ContainerValueNotFoundException * @throws InvalidArgumentException * @throws QueryExecutionException * @throws Exception * @throws ContainerException */ public function book($appointmentData, $reservation, $save); /** @noinspection MoreThanThreeArgumentsInspection */ /** * @param CommandResult $result * @param array $appointmentData * @param Reservation $reservation * @param bool $save * * @return void * * @throws ContainerValueNotFoundException * @throws InvalidArgumentException * @throws QueryExecutionException * @throws Exception * @throws ContainerException */ public function processBooking($result, $appointmentData, $reservation, $save); /** * @param CommandResult $result * @param Reservation $reservation * @param BookingType $bookingType * * @throws ContainerException */ public function finalize($result, $reservation, $bookingType); /** * @param CustomerBooking $booking * @param AbstractBookable $bookable * * @return float * * @throws InvalidArgumentException */ public function getPaymentAmount($booking, $bookable); /** * @param Appointment|Event $reservation * @param CustomerBooking $booking * @param AbstractBookable $bookable * * @return array */ public function getBookingPeriods($reservation, $booking, $bookable); /** * @return string */ public function getType(); /** * @param array $data * * @return AbstractBookable * * @throws ContainerValueNotFoundException * @throws QueryExecutionException * @throws ContainerException */ public function getBookableEntity($data); /** * @param Service|Event $bookable * * @return boolean */ public function isAggregatedPrice($bookable); /** * @param BooleanValueObject $bookableAggregatedPrice * @param BooleanValueObject $extraAggregatedPrice * * @return boolean */ public function isExtraAggregatedPrice($extraAggregatedPrice, $bookableAggregatedPrice); /** * @param Reservation $reservation * @param string $paymentGateway * @param array $requestData * * @return array * * @throws InvalidArgumentException */ public function getWooCommerceData($reservation, $paymentGateway, $requestData); /** * @param array $reservation * * @return array * * @throws InvalidArgumentException */ public function getWooCommerceDataFromArray($reservation, $index); /** * @param int $id * * @return Appointment|Event * * @throws ContainerValueNotFoundException * @throws QueryExecutionException * @throws ContainerException * @throws InvalidArgumentException */ public function getReservationByBookingId($id); /** * @param int $bookingId * * @return CommandResult * @throws InvalidArgumentException * @throws Exception */ public function getBookingResultByBookingId($bookingId); /** * @param DateTime $bookingStart * @param int $minimumCancelTime * * @return boolean * * @throws ContainerValueNotFoundException * @throws ContainerException * @throws BookingCancellationException */ public function inspectMinimumCancellationTime($bookingStart, $minimumCancelTime); /** * @param Reservation $reservation * @param BookingType $bookingType * * @return array */ public function getResultData($reservation, $bookingType); /** * @param bool $couponValidation * @param bool $customFieldsValidation * @param bool $availabilityValidation * * @return Reservation */ public function getNew($couponValidation, $customFieldsValidation, $availabilityValidation); /** * @param Payment $payment * @param boolean $fromLink * * @return CommandResult * @throws InvalidArgumentException * @throws Exception * @throws ContainerException */ public function getReservationByPayment($payment, $fromLink = false); /** * @param string $type * @param string $orderStatus * @param string $statusTarget * @param bool $isUpdate * * @return string|null */ public function getWcStatus($type, $orderStatus, $statusTarget, $isUpdate); } Services/User/ProviderService.php 0000666 00000057670 15165375612 0013127 0 ustar 00 <?php namespace AmeliaBooking\Domain\Services\User; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\Entity\Schedule\DayOff; use AmeliaBooking\Domain\Entity\Schedule\Period; use AmeliaBooking\Domain\Entity\Schedule\PeriodLocation; use AmeliaBooking\Domain\Entity\Schedule\SpecialDay; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriod; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriodLocation; use AmeliaBooking\Domain\Entity\Schedule\WeekDay; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Appointment\AppointmentFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodFactory; use AmeliaBooking\Domain\Factory\Schedule\WeekDayFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\Services\Interval\IntervalService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\String\Status; use DateTime; use DateTimeZone; use Exception; use Slim\Exception\ContainerValueNotFoundException; /** * Class ProviderService * * @package AmeliaBooking\Domain\Services\User */ class ProviderService { /** @var IntervalService */ private $intervalService; /** * ProviderService constructor. * * @param IntervalService $intervalService */ public function __construct( $intervalService ) { $this->intervalService = $intervalService; } /** * @param WeekDay|SpecialDay $day * * @return void * @throws InvalidArgumentException */ private function makePeriodsAvailable($day) { $periodsInSeconds = []; /** @var Period $period */ foreach ($day->getPeriodList()->getItems() as $key => $period) { if ($period->getLocationId()) { $startInSeconds = $this->intervalService->getSeconds( $period->getStartTime()->getValue()->format('H:i:s') ); $periodsInSeconds[$startInSeconds] = $this->intervalService->getSeconds( $period->getEndTime()->getValue()->format('H:i:s') ); } } if (!$periodsInSeconds) { $day->getPeriodList()->addItem( PeriodFactory::create( [ 'startTime' => '00:00:00', 'endTime' => '24:00:00', 'periodServiceList' => [], 'periodLocationList' => [], ] ) ); return; } $periodsStartTimes = array_keys($periodsInSeconds); sort($periodsStartTimes); $sortedPeriodsInSeconds = []; foreach ($periodsStartTimes as $seconds) { $sortedPeriodsInSeconds[$seconds] = $periodsInSeconds[$seconds]; } $periodsInSeconds = $sortedPeriodsInSeconds; $extraPeriods = []; $i = 0; $periodsCount = sizeof($periodsInSeconds); $periodsStarts = array_keys($periodsInSeconds); foreach ($periodsInSeconds as $secondsStart => $secondsEnd) { if ($i === 0) { if ($secondsStart !== 0) { $extraPeriods[0] = $secondsStart; } if (!empty($periodsStarts[$i + 1]) && $periodsStarts[$i + 1] !== $secondsEnd) { $extraPeriods[$secondsEnd] = $periodsStarts[$i + 1]; } if ($periodsCount === 1 && $secondsEnd !== 86400) { $extraPeriods[$secondsEnd] = 86400; } } elseif ($i === $periodsCount - 1) { if ($secondsEnd !== 86400) { $extraPeriods[$secondsEnd] = 86400; } } else { if ($periodsStarts[$i + 1] !== $secondsEnd) { $extraPeriods[$secondsEnd] = $periodsStarts[$i + 1]; } } $i++; } foreach ($extraPeriods as $extraPeriodStart => $extraPeriodEnd) { $day->getPeriodList()->addItem( PeriodFactory::create( [ 'startTime' => sprintf('%02d', floor($extraPeriodStart / 3600)) . ':' . sprintf('%02d', floor(($extraPeriodStart / 60) % 60)) . ':00', 'endTime' => sprintf('%02d', floor($extraPeriodEnd / 3600)) . ':' . sprintf('%02d', floor(($extraPeriodEnd / 60) % 60)) . ':00', 'periodServiceList' => [], 'periodLocationList' => [], ] ) ); } /** @var Collection $sortedPeriods */ $sortedPeriods = new Collection(); $allPeriodsInSeconds = []; /** @var Period $period */ foreach ($day->getPeriodList()->getItems() as $key => $period) { $startInSeconds = $this->intervalService->getSeconds( $period->getStartTime()->getValue()->format('H:i:s') ); $allPeriodsInSeconds[$startInSeconds] = $key; } $allPeriodsInSecondsKeys = array_keys($allPeriodsInSeconds); sort($allPeriodsInSecondsKeys); foreach ($allPeriodsInSecondsKeys as $periodStart) { $sortedPeriods->addItem($day->getPeriodList()->getItem($allPeriodsInSeconds[$periodStart])); } $day->setPeriodList($sortedPeriods); } /** * @param Collection $providers * * @return void * @throws InvalidArgumentException */ public function setProvidersAlwaysAvailable($providers) { /** @var Provider $provider */ foreach ($providers->getItems() as $k => $provider) { $providerWeekDayIndexes = []; /** @var WeekDay $weekDay */ foreach ($provider->getWeekDayList()->getItems() as $weekDay) { $providerWeekDayIndexes[] = $weekDay->getDayIndex()->getValue(); } for ($i = 1; $i <= 7; $i++) { if (!in_array($i, $providerWeekDayIndexes)) { $provider->getWeekDayList()->addItem( WeekDayFactory::create( [ 'dayIndex' => $i, 'startTime' => '00:00:00', 'endTime' => '00:00:00', 'timeOutList' => new Collection(), 'periodList' => new Collection( [ 'startTime' => '00:00:00', 'endTime' => '24:00:00', 'periodServiceList' => [], ] ) ] ) ); } } /** @var WeekDay $weekDay */ foreach ($provider->getWeekDayList()->getItems() as $index => $weekDay) { $this->makePeriodsAvailable($weekDay); } /** @var SpecialDay $specialDay */ foreach ($provider->getSpecialDayList()->getItems() as $specialDay) { $this->makePeriodsAvailable($specialDay); } $provider->setDayOffList(new Collection()); /** @var Collection $sortedPeriods */ $sortedWeekDays = new Collection(); $allWeekDaysIndexes = []; /** @var WeekDay $weekDay */ foreach ($provider->getWeekDayList()->getItems() as $key => $weekDay) { $allWeekDaysIndexes[$weekDay->getDayIndex()->getValue()] = $key; } $allWeekDaysKeysKeys = array_keys($allWeekDaysIndexes); sort($allWeekDaysKeysKeys); foreach ($allWeekDaysKeysKeys as $weekDayIndex) { $sortedWeekDays->addItem($provider->getWeekDayList()->getItem($allWeekDaysIndexes[$weekDayIndex])); } $provider->setWeekDayList($sortedWeekDays); } } /** * * @param Period|SpecialDayPeriod $period * @param Location $providerLocation * @param Collection $locations * @param bool $hasVisibleLocations * * @return Collection * * @throws ContainerValueNotFoundException * @throws InvalidArgumentException */ public function getProviderPeriodLocations($period, $providerLocation, $locations, $hasVisibleLocations) { /** @var Collection $availablePeriodLocations */ $availablePeriodLocations = new Collection(); if ($period->getPeriodLocationList()->length()) { /** @var PeriodLocation|SpecialDayPeriodLocation $periodLocation */ foreach ($period->getPeriodLocationList()->getItems() as $periodLocation) { if ($providerLocation && $periodLocation->getLocationId()->getValue() === $providerLocation->getId()->getValue() && ($hasVisibleLocations ? $providerLocation->getStatus()->getValue() === Status::VISIBLE : true) ) { $availablePeriodLocations->addItem($providerLocation, $providerLocation->getId()->getValue()); } } /** @var PeriodLocation|SpecialDayPeriodLocation $periodLocation */ foreach ($period->getPeriodLocationList()->getItems() as $periodLocation) { /** @var Location $availableLocation */ $availableLocation = $locations->keyExists($periodLocation->getLocationId()->getValue()) ? $locations->getItem($periodLocation->getLocationId()->getValue()) : null; if ($availableLocation && ( $providerLocation ? $periodLocation->getLocationId()->getValue() !== $providerLocation->getId()->getValue() : true ) && ($hasVisibleLocations ? $availableLocation->getStatus()->getValue() === Status::VISIBLE : true) ) { $availablePeriodLocations->addItem($availableLocation, $availableLocation->getId()->getValue()); } } } elseif ($period->getLocationId() && $period->getLocationId()->getValue()) { /** @var Location $availableLocation */ $availableLocation = $locations->keyExists($period->getLocationId()->getValue()) ? $locations->getItem($period->getLocationId()->getValue()) : null; if ($availableLocation && ($hasVisibleLocations ? $availableLocation->getStatus()->getValue() === Status::VISIBLE : true) ) { $availablePeriodLocations->addItem($availableLocation, $availableLocation->getId()->getValue()); } } elseif ($providerLocation && ($hasVisibleLocations ? $providerLocation->getStatus()->getValue() === Status::VISIBLE : true) ) { $availablePeriodLocations->addItem($providerLocation, $providerLocation->getId()->getValue()); } return $availablePeriodLocations; } /** * @param Provider $provider * @param Collection $services * @param bool $allowHiddenServices * * @return void * @throws InvalidArgumentException * @throws Exception */ public function setProviderServices($provider, $services, $allowHiddenServices) { /** @var Collection $providerServiceList */ $providerServiceList = new Collection(); /** @var Service $providerService */ foreach ($provider->getServiceList()->getItems() as $providerService) { if ($services->keyExists($providerService->getId()->getValue())) { /** @var Service $service */ $service = $services->getItem($providerService->getId()->getValue()); if ($allowHiddenServices ? true : $service->getStatus()->getValue() === Status::VISIBLE) { $providerServiceList->addItem( ServiceFactory::create( array_merge( $service->toArray(), [ 'price' => $providerService->getPrice()->getValue(), 'minCapacity' => $providerService->getMinCapacity()->getValue(), 'maxCapacity' => $providerService->getMaxCapacity()->getValue(), 'customPricing' => $providerService->getCustomPricing() ? $providerService->getCustomPricing()->getValue() : null, ] ) ), $service->getId()->getValue() ); } } } $provider->setServiceList($providerServiceList); } /** * Add appointments to provider's appointments list * * @param Collection $providers * @param Collection $appointments * @param bool $isGloballyBusySlot * * @throws InvalidArgumentException */ public function addAppointmentsToAppointmentList($providers, $appointments, $isGloballyBusySlot) { $appointmentsDateData = []; $appointmentsIdOrder = []; /** @var Appointment $appointment */ foreach ($appointments->getItems() as $appointmentId => $appointment) { $providerId = $appointment->getProviderId()->getValue(); $appointmentStart = $appointment->getBookingStart()->getValue()->format('Y-m-d H:i:s'); $appointmentEnd = $appointment->getBookingEnd()->getValue()->format('Y-m-d H:i:s'); if (!array_key_exists($providerId, $appointmentsDateData)) { $appointmentsDateData[$providerId] = [ ]; } $appointmentsIdOrder[] = $appointmentId; $lastIndex = sizeof($appointmentsIdOrder) - 1; if (!array_key_exists($appointmentStart, $appointmentsDateData[$providerId])) { $appointmentsDateData[$providerId][$appointmentStart] = [ 'id' => $appointmentId, 'end' => $appointmentEnd, 'index' => $lastIndex ]; } else if ($appointmentsDateData[$providerId][$appointmentStart]['end'] !== $appointmentEnd && DateTimeService::getCustomDateTimeObject($appointmentEnd) > DateTimeService::getCustomDateTimeObject($appointmentsDateData[$providerId][$appointmentStart]['end']) ) { $appointmentsIdOrder[$appointmentsDateData[$providerId][$appointmentStart]['index']] = $appointmentId; $appointmentsIdOrder[$lastIndex] = $appointmentsDateData[$providerId][$appointmentStart]['id']; } } $providerStarts = []; foreach ($appointmentsIdOrder as $index) { /** @var Appointment $appointment */ $appointment = $appointments->getItem($index); /** @var Provider $provider */ foreach ($providers->getItems() as $provider) { if (!array_key_exists($provider->getId()->getValue(), $providerStarts)) { $providerStarts[$provider->getId()->getValue()] = []; } $appointmentStartString = $appointment->getBookingStart()->getValue()->format('Y-m-d H:i:s'); if ($appointment->getProviderId()->getValue() === $provider->getId()->getValue() && array_key_exists($appointmentStartString, $providerStarts[$provider->getId()->getValue()]) ) { /** @var Appointment $duplicatedAppointment */ foreach ($provider->getAppointmentList()->getItems() as $duplicatedAppointment) { if ($duplicatedAppointment->getId() && in_array( $duplicatedAppointment->getId()->getValue(), $providerStarts[$provider->getId()->getValue()][$appointmentStartString] ) ) { /** @var CustomerBooking $booking */ foreach ($appointment->getBookings()->getItems() as $booking) { $duplicatedAppointment->getBookings()->addItem($booking, $booking->getId()->getValue()); } } } continue; } if ($appointment->getProviderId()->getValue() === $provider->getId()->getValue()) { $providerStarts[$provider->getId()->getValue()][$appointmentStartString][] = $appointment->getId()->getValue(); $provider->getAppointmentList()->addItem($appointment); if (!$isGloballyBusySlot) { break; } } else if ($isGloballyBusySlot) { $providerStarts[$provider->getId()->getValue()][$appointmentStartString][] = $appointment->getId()->getValue(); /** @var Appointment $fakeAppointment */ $fakeAppointment = AppointmentFactory::create( array_merge( $appointment->toArray(), ['providerId' => $provider->getId()->getValue()] ) ); if (!$fakeAppointment->getService()->getTimeBefore()) { $fakeAppointment->getService()->setTimeBefore(new Duration(0)); } if (!$fakeAppointment->getService()->getTimeAfter()) { $fakeAppointment->getService()->setTimeAfter(new Duration(0)); } $provider->getAppointmentList()->addItem($fakeAppointment); } } } } /** * @param Provider $provider * @param array $globalDaysOff * @param DateTime $startDateTime * @param DateTime $endDateTime * * @return void * @throws InvalidArgumentException */ public function modifyProviderTimeZone($provider, $globalDaysOff, $startDateTime, $endDateTime) { /** @var Appointment $appointment */ foreach ($provider->getAppointmentList()->getItems() as $appointment) { $appointment->getBookingStart()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); $appointment->getBookingEnd()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); } /** @var SpecialDay $specialDay */ foreach ($provider->getSpecialDayList()->getItems() as $specialDay) { $specialDay->setStartDate( new DateTimeValue( DateTimeService::getDateTimeObjectInTimeZone( $specialDay->getStartDate()->getValue()->format('Y-m-d') . ' 00:00:00', $provider->getTimeZone()->getValue() ) ) ); $specialDay->setEndDate( new DateTimeValue( DateTimeService::getDateTimeObjectInTimeZone( $specialDay->getEndDate()->getValue()->format('Y-m-d') . ' 00:00:00', $provider->getTimeZone()->getValue() ) ) ); } /** @var DayOff $dayOff */ foreach ($provider->getDayOffList()->getItems() as $dayOff) { $dayOff->setStartDate( new DateTimeValue( DateTimeService::getDateTimeObjectInTimeZone( $dayOff->getStartDate()->getValue()->format('Y-m-d') . ' 00:00:00', $provider->getTimeZone()->getValue() ) ) ); $dayOff->setEndDate( new DateTimeValue( DateTimeService::getDateTimeObjectInTimeZone( $dayOff->getEndDate()->getValue()->format('Y-m-d') . ' 00:00:00', $provider->getTimeZone()->getValue() ) ) ); } $yearsDiff = $startDateTime->diff($endDateTime)->format('%y'); $startYear = $startDateTime->format('Y'); /** @var Collection $fakeAppointments */ $fakeAppointments = new Collection(); foreach ($globalDaysOff as $globalDayOff) { $dayOffParts = explode('-', $globalDayOff); if (sizeof($dayOffParts) === 2) { for ($i = 0; $i <= $yearsDiff; $i++) { $dateOffStart = DateTimeService::getCustomDateTimeObject( $startYear . '-' . $globalDayOff . ' 00:00' )->modify("+$i years"); $dateOffEnd = DateTimeService::getCustomDateTimeObject( $startYear . '-' . $globalDayOff . ' 00:00' )->modify("+$i years")->modify('+1 days'); /** @var Appointment $fakeAppointment */ $fakeAppointment = AppointmentFactory::create( [ 'bookingStart' => $dateOffStart->format('Y-m-d H:i'), 'bookingEnd' => $dateOffEnd->format('Y-m-d H:i'), 'notifyParticipants' => false, 'serviceId' => 0, 'providerId' => $provider->getId()->getValue(), ] ); $fakeAppointment->getBookingStart()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); $fakeAppointment->getBookingEnd()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); $fakeAppointments->addItem($fakeAppointment); } } elseif (sizeof($dayOffParts) === 3) { /** @var Appointment $fakeAppointment */ $fakeAppointment = AppointmentFactory::create( [ 'bookingStart' => $globalDayOff . ' 00:00', 'bookingEnd' => DateTimeService::getCustomDateTimeObject( $globalDayOff . ' 00:00' )->modify('+1 days')->format('Y-m-d H:i'), 'notifyParticipants' => false, 'serviceId' => 0, 'providerId' => $provider->getId()->getValue(), ] ); $fakeAppointment->getBookingStart()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); $fakeAppointment->getBookingEnd()->getValue()->setTimezone( new DateTimeZone($provider->getTimeZone()->getValue()) ); $fakeAppointments->addItem($fakeAppointment); } } /** @var Appointment $fakeAppointment */ foreach ($fakeAppointments->getItems() as $fakeAppointment) { $provider->getAppointmentList()->addItem($fakeAppointment); } } } Collection/Collection.php 0000666 00000000257 15165375612 0011466 0 ustar 00 <?php namespace AmeliaBooking\Domain\Collection; /** * Class Collection * * @package AmeliaBooking\Domain\Collection */ class Collection extends AbstractCollection { } Collection/AbstractCollection.php 0000666 00000007105 15165375612 0013151 0 ustar 00 <?php namespace AmeliaBooking\Domain\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; /** * Class AbstractCollection * * @package AmeliaBooking\Domain\Collection */ class AbstractCollection { /** @var array|null */ protected $items = []; /** * AbstractCollection constructor. * * @param array $items * * @throws InvalidArgumentException */ public function __construct($items = null) { if (!is_array($items)) { return; } foreach ($items as $item) { $this->addItem($item); } $this->items = $items; } /** * Add an object to the collection by putting it in the $items array at a * specified location specified by $key (if no key is provided, we let * PHP pick the next available index). If an attempt is made to add an object * using a key that already exists, an exception should be thrown to prevent * inadvertently overwriting existing information * * @param $item * @param null $key * @param bool $force * * @throws InvalidArgumentException */ public function addItem($item, $key = null, $force = false) { if ($key !== null) { $this->placeItem($item, $key, $force); return; } $this->items[] = $item; } /** * Take the key as a parameter indicating which items are targeted for removal. * * @param $key * * @throws InvalidArgumentException */ public function deleteItem($key) { if (!$this->keyExists($key)) { throw new InvalidArgumentException("Invalid key {$key}."); } unset($this->items[$key]); } /** * Take the key as a parameter indicating which items are targeted for retrieval. * * @param $key * * @return mixed * @throws InvalidArgumentException */ public function getItem($key) { if (!$this->keyExists($key)) { throw new InvalidArgumentException("Invalid key {$key}."); } return $this->items[$key]; } /** * Returns items list * * @return array|null */ public function getItems() { return $this->items; } /** * List of keys to any external code * * @return array */ public function keys() { return array_keys($this->items); } /** * How many items are in the collection. * * @return int */ public function length() { return count($this->items); } /** * Determining whether a given key exists in the collection * * @param $key * * @return bool */ public function keyExists($key) { return isset($this->items[$key]); } /** * Place an item on the specific position * * @param $item * @param $key * @param $force * * @throws InvalidArgumentException */ public function placeItem($item, $key, $force) { if ($force === false && $this->keyExists($key)) { throw new InvalidArgumentException("Key {$key} already in use."); } $this->items[$key] = $item; } /** * Return an array of collection items * * @param $isFrontEndRequest * * @return array */ public function toArray($isFrontEndRequest = false) { $array = []; foreach ($this->items as $item) { $array[] = $item->toArray($isFrontEndRequest); } return $array; } }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings