/** * Créer un client à partir d'un tableau associatif ou à partir d'un nom / prénom / email * @param type $apiClient * @param array|string $arrayOuNom tableau clé / valeur des propriétés du client ou nom du client * @param string $prenom [OPTIONNEL] prénom du client * @param string $email [OPTIONNEL] email du client * @param string $email2[OPTIONNEL] email de confirmation du client. Si non null doit être identique au mail * @throws \LogicException si vous ne respectez pas l'une des deux manières d'instancier l'objet */ public function __construct($apiClient, $arrayOuNom, $prenom = NULL, $email = NULL, $email2 = NULL) { if (is_string($arrayOuNom) && $arrayOuNom && $prenom && $email) { //construct à partir de nom, prenom, e-mail, e-mail2 $arrayOuNom = array("nom" => $arrayOuNom, "prenom" => $prenom, "email" => $email, "email2" => $email2); } if (is_array($arrayOuNom)) { //construction à la manière de faire un restGET parent::__construct($apiClient, $arrayOuNom); } else { throw new \LogicException("Un client peut être instancié à l'aide d'un tableau clé - valeur ou alors son nom, son prénom , son mail et son email de confirmation"); } }
public function __get($name) { if ("nbrJours" == $name && null == $this->_nbrJours) { $nbJours = 0; if (!empty($this->_prestationsPanier)) { /** @var PrestationPanier $prestationPanier */ foreach ($this->_prestationsPanier as $prestationPanier) { $aDateArrivee = explode("/", $prestationPanier->debut); $sDateArrivee = $aDateArrivee['2'] . "-" . $aDateArrivee['1'] . "-" . $aDateArrivee['0']; $aDateDepart = explode("/", $prestationPanier->fin); $sDateDepart = $aDateDepart['2'] . "-" . $aDateDepart['1'] . "-" . $aDateDepart['0']; $oInterval = date_diff(new \DateTime($sDateArrivee), new \DateTime($sDateDepart)); $nbJours += $oInterval->format('%a'); } $this->_nbrJours = $nbJours; return $nbJours; } else { throw new \SitecRESA\Exception\Api("Vous n'avez aucune prestationPanier"); } } else { return parent::__get($name); } }
public function __get($name) { $retour = parent::__get($name); if (null === $retour && $this->_panier != null && "planTarifaire" == $name && null == $this->_planTarifaire) { $oDispoProduit = $this->prestation->disponibilites($this->_debut, $this->_fin, $this->_prestataire->resolve()); if ($oDispoProduit instanceof AccesResolverList) { foreach ($oDispoProduit as $dispoProduit) { foreach ($dispoProduit->plansTarifaires as $oPlanTarifaire) { if ($oPlanTarifaire->id == $this->_idPlanTarifaire) { $this->_planTarifaire = $oPlanTarifaire; return $this->_planTarifaire; } } } } else { foreach ($oDispoProduit->plansTarifaires as $oPlanTarifaire) { if ($oPlanTarifaire->id == $this->_idPlanTarifaire) { $this->_planTarifaire = $oPlanTarifaire; return $this->_planTarifaire; } } } } return $retour; }