setTagLong($tagLong); $this->setTagShort($tagShort); } /** * Est-ce la valeur correspond au tag court ou long ? * * Utilisé par les classes enfants pour savoir si le tag correspond. * * @param string $arg La valeur à examiner. * * @return boolean True si le tag correspond, sinon False. */ protected function _parseTag($arg) { if($this->hasTagShort()) { if ($arg == '-'.$this->getTagShort()) return true; } return $arg == '--'.$this->getTagLong(); } public function getTagShort() { return $this->_tagShort; } /** * Définit le tag court. * * @param string|null $tagShort Le tage court. * * @return $this * * @see $_tagShort */ public function setTagShort($tagShort = null) { $this->_tagShort = $tagShort; return $this; } /** * Est-ce que l'argument existe en forme courte ? * * @return boolean True si existe en forme courte, sinon False. */ public function hasTagShort() { return !is_null($this->_tagShort); } public function getTagLong() { return $this->_tagLong; } /** * Définit le tag long. * * Si non fourni, est déduit du {@see $_name nom de l'argument} : * - Les "_" sont remplacés par "-" * - Les lettres majuscules sont remplacées par "-" suivit de la lettre en minuscule * * @param string|null $tagLong Le tag long. * * @return $this * * @see $_tagLong */ public function setTagLong($tagLong = null) { $this->_tagLong = $tagLong; if(is_null($this->_tagLong)) { $this->_tagLong = preg_replace_callback( '/[A-Z_]/', function ($matches) { if($matches[0] == '_') return '-'; else return '-'.strtolower($matches[0]); }, $this->getName() ); } return $this; } public function allowMultiple() { return $this->_multiple; } /** * Définit si l'argument est autorisé plusieurs fois ou non. * * @param boolean $multiple Argument autorisé plusieurs fois ? * * @return $this * * @throws InvalidArgument Si la valeur n'est pas un booléen * * @see $_optional */ public function setMultiple($multiple) { if (!is_bool($multiple)) throw new InvalidArgument($multiple, 'La valeur n\'est pas un booléen'); $this->_multiple = $multiple; return $this; } public function isStoppingParse() { return $this->_isStoppingParse; } /** * Définit si l'argument met fin au parsage ou non. * * @param boolean $stoppingParse Met fin au parsage ? * * @return $this * * @throws InvalidArgument Si la valeur n'est pas un booléen * * @see $_optional */ public function setStoppingParse($stoppingParse) { if (!is_bool($stoppingParse)) throw new InvalidArgument($stoppingParse, 'La valeur n\'est pas un booléen'); $this->_isStoppingParse = $stoppingParse; return $this; } }