/** * @param array $existingVehicleInspection * @param \Madkom\RegistryApplication\Domain\CarManagement\VehicleInspection\VehicleInspection $newVehicleInspection * * @return bool */ public function checkForDuplicates(array $existingVehicleInspection, VehicleInspection $newVehicleInspection) { /** @var VehicleInspection $vehicleInspection */ foreach ($existingVehicleInspection as $vehicleInspection) { if ($newVehicleInspection->getLastInspection() === $vehicleInspection->getLastInspection() || $newVehicleInspection->getId() === $vehicleInspection->getId()) { return true; } } return false; }