<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Model;
use Croisiland\CommonBundle\Entity\Company\Company;
use Croisiland\CommonBundle\Entity\Itinerary\DestinationMain;
use Croisiland\CommonBundle\Entity\Itinerary\DestinationSecondary;
use Croisiland\CommonBundle\Entity\Itinerary\Stopover;
use Croisiland\CommonBundle\Entity\Offer\Offer;
use Croisiland\CommonBundle\Entity\Partner\Partner;
use Croisiland\CommonBundle\Entity\Ship\Ship;
use Croisiland\CommonBundle\Entity\Tag\Tag;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
class CruiseSearchModel
{
/**
* @var Collection<int, Company> companies Ids
*/
private Collection $companies;
/**
* @var Collection<int, Ship> ship Ids
*/
private Collection $ships;
/**
* @var Collection<int, Stopover> first Itinerary Segment stopover Id
*/
private Collection $departurePorts;
/**
* @var Collection<int, DestinationMain> Main Destinations
*/
private Collection $destinationsMain;
/**
* @var Collection<int, DestinationSecondary> Secondary Destinations
*/
private Collection $destinationsSecondary;
/**
* @var Collection<int, Tag> tag Ids
*/
private Collection $tags;
/**
* @var Collection<int, Offer> offer Ids
*/
private Collection $offers;
private ?Partner $partner = null;
private ?\DateTimeInterface $periodStartDate = null;
private ?\DateTimeInterface $periodEndDate = null;
private ?int $priceMinimum = null;
private ?int $priceMaximum = null;
private ?string $keywords = null;
private ?string $cruiseCode = null;
/**
* @var array<string> durations in range days min-max where min or max can be set to x for 0 or infinite.
*/
private array $durations = [];
/**
* if worldTour or not, null for all cruises.
*/
private ?bool $worldTour = null;
private ?string $sortProperty = null;
private ?string $sortOrder = null;
private ?int $page = null;
private ?int $perPage = null;
private bool $randomized = false;
public const int DEFAULT_PAGE = 1;
public const int DEFAULT_PER_PAGE = 10;
public const string DEFAULT_SORT_PROPERTY = 'departureDate';
public const string DEFAULT_SORT_ORDER = 'ASC';
public function __construct()
{
$this->companies = new ArrayCollection();
$this->ships = new ArrayCollection();
$this->departurePorts = new ArrayCollection();
$this->destinationsMain = new ArrayCollection();
$this->destinationsSecondary = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->offers = new ArrayCollection();
}
/**
* @return array<string, mixed> propertyName => value
*/
public function getProperties(): array
{
return get_object_vars($this);
}
/**
* @return Collection<int, Company>
*/
public function getCompanies(): Collection
{
return $this->companies;
}
/**
* @param Collection<int, Company> $companies
*/
public function setCompanies(Collection $companies): static
{
$this->companies = $companies;
return $this;
}
public function addCompany(Company $company): static
{
$this->companies->add($company);
return $this;
}
/**
* @return Collection<int, Ship>
*/
public function getShips(): Collection
{
return $this->ships;
}
/**
* @param Collection<int, Ship> $ships
*/
public function setShips(Collection $ships): static
{
$this->ships = $ships;
return $this;
}
public function addShip(Ship $ship): static
{
$this->ships->add($ship);
return $this;
}
/**
* @return Collection<int, Stopover>
*/
public function getDeparturePorts(): Collection
{
return $this->departurePorts;
}
/**
* @param Collection<int, Stopover> $departurePorts
*/
public function setDeparturePorts(Collection $departurePorts): static
{
$this->departurePorts = $departurePorts;
return $this;
}
public function addDeparturePort(Stopover $port): static
{
$this->departurePorts->add($port);
return $this;
}
/**
* @return Collection<int, DestinationMain>
*/
public function getDestinationsMain(): Collection
{
return $this->destinationsMain;
}
/**
* @param Collection<int, DestinationMain> $destinationsMain
*/
public function setDestinationsMain(Collection $destinationsMain): static
{
$this->destinationsMain = $destinationsMain;
return $this;
}
public function addDestinationMain(DestinationMain $destination): static
{
$this->destinationsMain->add($destination);
return $this;
}
/**
* @return Collection<int, DestinationSecondary>
*/
public function getDestinationsSecondary(): Collection
{
return $this->destinationsSecondary;
}
/**
* @param Collection<int, DestinationSecondary> $destinationsSecondary
*/
public function setDestinationsSecondary(Collection $destinationsSecondary): static
{
$this->destinationsSecondary = $destinationsSecondary;
return $this;
}
public function addDestinationSecondary(DestinationSecondary $destination): static
{
$this->destinationsSecondary->add($destination);
return $this;
}
public function destinationsIsSet(): bool
{
return !$this->destinationsSecondary->isEmpty() || !$this->destinationsMain->isEmpty();
}
/**
* @return Collection<int,Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
/**
* @param Collection<int,Tag> $tags
*/
public function setTags(Collection $tags): static
{
$this->tags = $tags;
return $this;
}
public function addTag(Tag $tag): static
{
$this->tags->add($tag);
return $this;
}
/**
* @return Collection<int, Offer>
*/
public function getOffers(): Collection
{
return $this->offers;
}
/**
* @param Collection<int, Offer> $offers
*/
public function setOffers(Collection $offers): static
{
$this->offers = $offers;
return $this;
}
public function addOffer(Offer $offer): static
{
$this->offers->add($offer);
return $this;
}
public function getPartner(): ?Partner
{
return $this->partner;
}
public function setPartner(?Partner $partner): static
{
$this->partner = $partner;
return $this;
}
public function getPeriodStartDate(): ?\DateTimeInterface
{
return $this->periodStartDate;
}
public function setPeriodStartDate(?\DateTimeInterface $periodStartDate): static
{
$this->periodStartDate = $periodStartDate;
return $this;
}
public function getPeriodEndDate(): ?\DateTimeInterface
{
return $this->periodEndDate;
}
public function setPeriodEndDate(?\DateTimeInterface $periodEndDate): static
{
if ($periodEndDate) {
/** @var DateTime $periodEndDate */
$periodEndDate->setTime(23, 59, 59);
}
$this->periodEndDate = $periodEndDate;
return $this;
}
public function periodIsSet(): bool
{
return null !== $this->periodEndDate || null !== $this->periodStartDate;
}
/**
* @return string[]
*/
public function getDurations(): array
{
return $this->durations;
}
/**
* @param string[] $durations
*/
public function setDurations(array $durations): static
{
$this->durations = $durations;
return $this;
}
public function getWorldTour(): ?bool
{
return $this->worldTour;
}
public function setWorldTour(?bool $worldTour): static
{
$this->worldTour = $worldTour;
return $this;
}
public function getSortProperty(): ?string
{
return $this->sortProperty;
}
public function setSortProperty(?string $sortProperty): static
{
$this->sortProperty = $sortProperty;
return $this;
}
public function getPriceMinimum(): ?int
{
return $this->priceMinimum;
}
public function setPriceMinimum(?int $priceMinimum): static
{
$this->priceMinimum = $priceMinimum;
return $this;
}
public function getPriceMaximum(): ?int
{
return $this->priceMaximum;
}
public function setPriceMaximum(?int $priceMaximum): static
{
$this->priceMaximum = $priceMaximum;
return $this;
}
public function priceRangeIsSet(): bool
{
return null !== $this->priceMaximum || null !== $this->priceMinimum;
}
public function getSortOrder(): ?string
{
return $this->sortOrder;
}
public function setSortOrder(?string $sortOrder): static
{
$this->sortOrder = $sortOrder;
return $this;
}
public function getPage(): ?int
{
return $this->page;
}
public function setPage(?int $page): static
{
$this->page = max(1, $page);
return $this;
}
public function getPerPage(): ?int
{
return $this->perPage;
}
public function setPerPage(?int $perPage): static
{
$this->perPage = max(1, $perPage);
return $this;
}
public function getOffset(): int
{
return ($this->page - 1) * $this->perPage;
}
public function getLimit(): ?int
{
return $this->perPage;
}
public function getKeywords(): ?string
{
return $this->keywords;
}
public function setKeywords(?string $keywords): static
{
$this->keywords = $keywords;
return $this;
}
public function getCruiseCode(): ?string
{
return $this->cruiseCode;
}
public function setCruiseCode(?string $cruiseCode): static
{
$this->cruiseCode = $cruiseCode;
return $this;
}
public function isRandomized(): bool
{
return $this->randomized;
}
public function setRandomized(bool $randomized): CruiseSearchModel
{
$this->randomized = $randomized;
return $this;
}
}