/** * Enforce operational constraints for ride nodes and node lists: * * constraint 1: vehicle capacity (seats, wheelchairs) not exceeded * constraint 2: compatibility passenger(s) and vehicle (true) * constraint 3: compatibility passenger(s) and driver (true) * * return true if anything is wrong (taboo, sometimes also called tabu) * * @param RideNodeList $rideNodeList * @param RideNode $rideNode * @return bool */ public function isTaboo(RideNodeList $rideNodeList, RideNode $rideNode) { $vehicle = $rideNodeList->getVehicle(); if (null !== $vehicle) { // constraint 1: vehicle capacity (resources) $vehicleCat = $vehicle->getCategory(); if ($rideNode->passengers > $vehicleCat->getAmountOfSeats() or $rideNode->wheelChairs > $vehicleCat->getAmountOfWheelChairs()) { return true; } // constraint 2: compatibility of vehicle category and passenger(s) $contradicting = $rideNode->contradictingVehicleCategories; if (null !== $contradicting) { if (array_key_exists($vehicleCat->getId(), $contradicting)) { return true; } } } // todo constraint 3: compatibility passenger(s) and driver tested here... return false; }