Code reorganization (PSR-4)
parent
f950043b9c
commit
0742795afa
@ -1,19 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\IArgumentValueDescription
|
||||
*/
|
||||
namespace CommandLine\Argument;
|
||||
|
||||
/**
|
||||
* Interface à implementer par les arguments qui souhaitent détailler la valeur attendue
|
||||
*
|
||||
* @package CommandLine\Argument
|
||||
*/
|
||||
interface IArgumentValueDescription {
|
||||
/**
|
||||
* La description de la valeur de d'argument.
|
||||
*
|
||||
* @return string La description.
|
||||
*/
|
||||
public function getValueDescription();
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\IArgumentValueDescription
|
||||
*/
|
||||
namespace CommandLine\Argument;
|
||||
|
||||
/**
|
||||
* Interface à implementer par les arguments qui souhaitent détailler la valeur attendue
|
||||
*
|
||||
* @package CommandLine\Argument
|
||||
*/
|
||||
interface IArgumentValueDescription {
|
||||
/**
|
||||
* La description de la valeur de d'argument.
|
||||
*
|
||||
* @return string La description.
|
||||
*/
|
||||
public function getValueDescription();
|
||||
}
|
@ -1,48 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclare la classe CommandLine\Argument\Option\OptionFlagWithReverse.
|
||||
*/
|
||||
namespace CommandLine\Argument\Option;
|
||||
|
||||
/**
|
||||
* Option de type "flag" : vaut True ou False avec son tag inversé.
|
||||
*
|
||||
* Le tag long inversé est automatiquement généré en préfixant avec "no-" sauf si l'initial commence déjà par "no-".
|
||||
* Le tag court inversé est fait de la même manière, mais avec le préfixe "n".
|
||||
*
|
||||
* Exemples :
|
||||
* - "--force" donne "--no-force"
|
||||
* - "-f" donne "-nf"
|
||||
* - "--no-stop" devient "--stop"
|
||||
*
|
||||
* @package CommandLine\Argument\Option
|
||||
*/
|
||||
class FlagWithReverse extends Flag implements IArgumentOptionSecondary {
|
||||
public function getOthersOptions () {
|
||||
$tagShort = null;
|
||||
if($this->hasTagShort()) {
|
||||
if(substr($this->getTagShort(), 0, 1) == 'n')
|
||||
$tagShort = substr($this->getTagShort(), 1);
|
||||
else
|
||||
$tagShort = 'n'.$this->getTagShort();
|
||||
}
|
||||
|
||||
if(substr($this->getTagLong(), 0, 3) == 'no-')
|
||||
$tagLong = substr($this->getTagLong(), 3);
|
||||
else
|
||||
$tagLong = 'no-'.$this->getTagLong();
|
||||
|
||||
$name = $this->getName();
|
||||
if(substr($name, 0, 3) == 'no')
|
||||
$name = strtolower(substr($name, 2, 1)).substr($name, 3);
|
||||
else
|
||||
$name = 'no'.strtoupper(substr($name, 0, 1)).substr($name, 1);
|
||||
|
||||
$description = '[INVERSE] '.$this->getDescription();
|
||||
|
||||
$reverse = new Flag($name, !$this->getDefault(), $description, $tagLong, $tagShort);
|
||||
$reverse->setVarName($this->getVarName());
|
||||
|
||||
return array($reverse);
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Déclare la classe CommandLine\Argument\Option\OptionFlagWithReverse.
|
||||
*/
|
||||
namespace CommandLine\Argument\Option;
|
||||
|
||||
/**
|
||||
* Option de type "flag" : vaut True ou False avec son tag inversé.
|
||||
*
|
||||
* Le tag long inversé est automatiquement généré en préfixant avec "no-" sauf si l'initial commence déjà par "no-".
|
||||
* Le tag court inversé est fait de la même manière, mais avec le préfixe "n".
|
||||
*
|
||||
* Exemples :
|
||||
* - "--force" donne "--no-force"
|
||||
* - "-f" donne "-nf"
|
||||
* - "--no-stop" devient "--stop"
|
||||
*
|
||||
* @package CommandLine\Argument\Option
|
||||
*/
|
||||
class FlagWithReverse extends Flag implements IArgumentOptionSecondary {
|
||||
public function getOthersOptions () {
|
||||
$tagShort = null;
|
||||
if($this->hasTagShort()) {
|
||||
if(substr($this->getTagShort(), 0, 1) == 'n')
|
||||
$tagShort = substr($this->getTagShort(), 1);
|
||||
else
|
||||
$tagShort = 'n'.$this->getTagShort();
|
||||
}
|
||||
|
||||
if(substr($this->getTagLong(), 0, 3) == 'no-')
|
||||
$tagLong = substr($this->getTagLong(), 3);
|
||||
else
|
||||
$tagLong = 'no-'.$this->getTagLong();
|
||||
|
||||
$name = $this->getName();
|
||||
if(substr($name, 0, 3) == 'no')
|
||||
$name = strtolower(substr($name, 2, 1)).substr($name, 3);
|
||||
else
|
||||
$name = 'no'.strtoupper(substr($name, 0, 1)).substr($name, 1);
|
||||
|
||||
$description = '[INVERSE] '.$this->getDescription();
|
||||
|
||||
$reverse = new Flag($name, !$this->getDefault(), $description, $tagLong, $tagShort);
|
||||
$reverse->setVarName($this->getVarName());
|
||||
|
||||
return array($reverse);
|
||||
}
|
||||
}
|
@ -1,46 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\Option\IArgumentOption
|
||||
*/
|
||||
namespace CommandLine\Argument\Option;
|
||||
|
||||
use CommandLine\Argument\IArgument;
|
||||
|
||||
/**
|
||||
* Interface à implémenter si l'argument est de type "option"
|
||||
*
|
||||
* @package CommandLine\Argument\Option
|
||||
*/
|
||||
interface IArgumentOption extends IArgument {
|
||||
/**
|
||||
* La tag court.
|
||||
*
|
||||
* @return string|null Le tag court.
|
||||
*
|
||||
* @see $_tagShort
|
||||
*/
|
||||
public function getTagShort();
|
||||
/**
|
||||
* Le tag long.
|
||||
*
|
||||
* @return string Le tag long.
|
||||
*
|
||||
* @see $_tagLong
|
||||
*/
|
||||
public function getTagLong();
|
||||
|
||||
/**
|
||||
* Est-ce que l'argument est autorisé plusieurs fois ?
|
||||
*
|
||||
* @return boolean True si l'argument est autorisé plusieurs fois, sinon False
|
||||
*/
|
||||
public function allowMultiple();
|
||||
/**
|
||||
* Est-ce que l'argument met fin au parsage ?
|
||||
*
|
||||
* Exemple : --help = affiche l'aide et stoppe le programme
|
||||
*
|
||||
* @return boolean True si la présence de l'argument mat fin au parsage, sinon False.
|
||||
*/
|
||||
public function isStoppingParse();
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\Option\IArgumentOption
|
||||
*/
|
||||
namespace CommandLine\Argument\Option;
|
||||
|
||||
use CommandLine\Argument\IArgument;
|
||||
|
||||
/**
|
||||
* Interface à implémenter si l'argument est de type "option"
|
||||
*
|
||||
* @package CommandLine\Argument\Option
|
||||
*/
|
||||
interface IArgumentOption extends IArgument {
|
||||
/**
|
||||
* La tag court.
|
||||
*
|
||||
* @return string|null Le tag court.
|
||||
*
|
||||
* @see $_tagShort
|
||||
*/
|
||||
public function getTagShort();
|
||||
/**
|
||||
* Le tag long.
|
||||
*
|
||||
* @return string Le tag long.
|
||||
*
|
||||
* @see $_tagLong
|
||||
*/
|
||||
public function getTagLong();
|
||||
|
||||
/**
|
||||
* Est-ce que l'argument est autorisé plusieurs fois ?
|
||||
*
|
||||
* @return boolean True si l'argument est autorisé plusieurs fois, sinon False
|
||||
*/
|
||||
public function allowMultiple();
|
||||
/**
|
||||
* Est-ce que l'argument met fin au parsage ?
|
||||
*
|
||||
* Exemple : --help = affiche l'aide et stoppe le programme
|
||||
*
|
||||
* @return boolean True si la présence de l'argument mat fin au parsage, sinon False.
|
||||
*/
|
||||
public function isStoppingParse();
|
||||
}
|
@ -1,31 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\Option\IArgumentValue
|
||||
*/
|
||||
namespace CommandLine\Argument\Value;
|
||||
|
||||
use CommandLine\Argument\IArgument;
|
||||
|
||||
/**
|
||||
* Interface à implémenter si l'argument est de type "valeur"
|
||||
*
|
||||
* @package CommandLine\Argument\value
|
||||
*/
|
||||
interface IArgumentValue extends IArgument {
|
||||
/**
|
||||
* Le nombre minimum d'occurence.
|
||||
*
|
||||
* Généralement 0 (falcultatif) ou 1 (obligatoire).
|
||||
*
|
||||
* @return int Le nombre minimum d'occurence
|
||||
*/
|
||||
public function getOccurMin();
|
||||
/**
|
||||
* Le nombre maximum d'occurence.
|
||||
*
|
||||
* Généralement 1 ou Null (illimité).
|
||||
*
|
||||
* @return int|null Le nombre maximum d'occurence
|
||||
*/
|
||||
public function getOccurMax();
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface CommandLine\Argument\Option\IArgumentValue
|
||||
*/
|
||||
namespace CommandLine\Argument\Value;
|
||||
|
||||
use CommandLine\Argument\IArgument;
|
||||
|
||||
/**
|
||||
* Interface à implémenter si l'argument est de type "valeur"
|
||||
*
|
||||
* @package CommandLine\Argument\value
|
||||
*/
|
||||
interface IArgumentValue extends IArgument {
|
||||
/**
|
||||
* Le nombre minimum d'occurence.
|
||||
*
|
||||
* Généralement 0 (falcultatif) ou 1 (obligatoire).
|
||||
*
|
||||
* @return int Le nombre minimum d'occurence
|
||||
*/
|
||||
public function getOccurMin();
|
||||
/**
|
||||
* Le nombre maximum d'occurence.
|
||||
*
|
||||
* Généralement 1 ou Null (illimité).
|
||||
*
|
||||
* @return int|null Le nombre maximum d'occurence
|
||||
*/
|
||||
public function getOccurMax();
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface d'exception CommandLine\Exception\IException.
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
/**
|
||||
* Interface pour toutes les exceptions du module.
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*/
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'interface d'exception CommandLine\Exception\IException.
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
/**
|
||||
* Interface pour toutes les exceptions du module.
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*/
|
||||
interface IException {}
|
@ -1,17 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'exception CommandLine\Exception\MissingArgument
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
use CommandLine\Solution;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception levée quand un argument est manquant lors d'un parsage d'une solution
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*
|
||||
* @see Solution::parseExplicit()
|
||||
*/
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'exception CommandLine\Exception\MissingArgument
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception levée quand un argument est manquant lors d'un parsage d'une solution
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*
|
||||
* @see Solution::parseExplicit()
|
||||
*/
|
||||
class MissingArgument extends RuntimeException implements IException {}
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'exception CommandLine\Exception\TooMushValues
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception levée quand il y a des valeurs en trop lors d'un parsage d'une solution
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*/
|
||||
<?php
|
||||
/**
|
||||
* Déclaration de l'exception CommandLine\Exception\TooMushValues
|
||||
*/
|
||||
namespace CommandLine\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception levée quand il y a des valeurs en trop lors d'un parsage d'une solution
|
||||
*
|
||||
* @package CommandLine\Exception
|
||||
*/
|
||||
class TooMuchValues extends RuntimeException implements IException {}
|
Loading…
Reference in New Issue