ressources = $ressources; $this->projetsDispo = $projetsDispo; $this->servicesDispo = $servicesDispo; } public function verifier() { $this->verifierPresenceRessources(); $this->verifierPresenceProjet(); $this->verifierPresenceService(); } private function verifierPresenceRessources() { if ($this->ressources->getNombre() == 0) { $message = "Aucune ressource n'a été indiquée.\n". "Veuillez indiquer au moins un code de projet et un type de service."; $code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE; throw new Exception($message, $code); } } private function verifierPresenceProjet() { $projet = $this->ressources->getProjetNom(); if (in_array($projet, $this->projetsDispo) === false) { $message = "La ressource '$projet' n'indique pas un projet existant.\n". "Les projets existant sont :\n".implode(', ', $this->projetsDispo); $code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE; throw new Exception($message, $code); } } private function verifierPresenceService() { $service = $this->ressources->getServiceNom(); if (in_array($service, $this->servicesDispo) === false) { $message = "La service demandé '$service' n'est pas disponible pour le projet '{$this->ressources->getProjetNom()}' !\n". "Les services disponibles sont : ".implode(', ', $this->servicesDispo); $code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; throw new Exception($message, $code); } } } ?>