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