public function getQuantityAndDurationForService(Service $service, $nbNights, $nbPax, $nbAdults = null, $nbChildren = null) { if ($nbAdults === null) { $nbAdults = $this->datePaxData->getTotalAdults(); } if ($nbChildren === null) { $nbChildren = $this->datePaxData->getTotalChildren(); } $quantity = 1; $duration = 0; if ($service->getDetails()->getPricePerNight() and (!$service->getNightRequested() or $service->getMandatory())) { $duration += max(1, $this->datePaxData->getNbNights()); } elseif (($service->getDetails()->getPricePerNight() or $service->getNightRequested()) and $nbNights) { $duration += $nbNights; } if ($service->getDetails()->getPricePerPax() and (!$service->getPaxRequested() or $service->getMandatory())) { $quantity = 1; $nbPax = 0; if ($service->getDetails()->getChild()) { $nbPax += $nbChildren; } if ($service->getDetails()->getAdult()) { $nbPax += $nbAdults; } $quantity *= $nbPax; } elseif ($service->getDetails()->getPricePerPax()) { $quantity = (int) $nbPax; } return array('quantity' => $quantity, 'duration' => $duration); }