Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Enterprise\BoxOffice\Services\Domain;
use HiEvents\DomainObjects\Enums\PromoCodeDiscountAppliesToEnum;
use HiEvents\DomainObjects\Enums\PromoCodeDiscountTypeEnum;
use HiEvents\DomainObjects\PromoCodeDomainObject;
use HiEvents\Enterprise\BoxOffice\Services\Application\Handlers\Public\DTO\BoxOfficeDiscountDTO;
class BoxOfficeDiscountFactory
{
public function fromDiscount(?BoxOfficeDiscountDTO $discount, int $eventId): ?PromoCodeDomainObject
{
if ($discount === null || $discount->value <= 0) {
return null;
}
$isFixed = $discount->type === PromoCodeDiscountTypeEnum::FIXED->name;
return (new PromoCodeDomainObject)
->setEventId($eventId)
->setCode('box-office')
->setDiscount($discount->value)
->setDiscountType($isFixed ? PromoCodeDiscountTypeEnum::FIXED->name : PromoCodeDiscountTypeEnum::PERCENTAGE->name)
->setDiscountAppliesTo($isFixed ? PromoCodeDiscountAppliesToEnum::ORDER->name : PromoCodeDiscountAppliesToEnum::EACH_PRODUCT->name)
->setApplicableProductIds(null);
}
}