You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
PHP
74 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Déclaration de CommandLine\Argument\Value\FixedValue
|
|
*/
|
|
namespace CommandLine\Argument\Value;
|
|
|
|
use CommandLine\Argument\IArgumentValueDescription;
|
|
use CommandLine\Argument\ParseResult;
|
|
|
|
/**
|
|
* Argument devant correspondre une valeur fixe
|
|
*
|
|
* @package CommandLine\Argument
|
|
*/
|
|
class FixedValue extends ValueAbstract implements IArgumentValueDescription {
|
|
/**
|
|
* @var string La valeur que doit avoir l'argument
|
|
*/
|
|
protected $_value;
|
|
|
|
/**
|
|
* Crée un nouvel argument de type valeur
|
|
*
|
|
* @param string $varName Le nom de la variable
|
|
* @param string $value La valeur
|
|
* @param string|null $description La description
|
|
* @param boolean $optional Valeur optionnelle ?
|
|
*/
|
|
public function __construct ($varName, $value, $description, $optional = false) {
|
|
parent::__construct($value, $description, $optional);
|
|
$this->setVarName($varName);
|
|
$this->setValue($value);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function parse ($args) {
|
|
if($args[0] == $this->getValue())
|
|
return new ParseResult($this->getValue(), 1);
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getValueDescription () {
|
|
return '"'.$this->getValue().'"';
|
|
}
|
|
|
|
/**
|
|
* La valeur.
|
|
*
|
|
* @return string La valeur.
|
|
*
|
|
* @see $_value
|
|
*/
|
|
public function getValue() {
|
|
return $this->_value;
|
|
}
|
|
/**
|
|
* Définit la valeur
|
|
*
|
|
* @param string $value La valeur
|
|
*
|
|
* @return $this
|
|
* @see $_value
|
|
*/
|
|
public function setValue($value) {
|
|
$this->_value = $value;
|
|
return $this;
|
|
}
|
|
} |