@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * IntegerParameter.php |
|
| 5 | - */ |
|
| 4 | + * IntegerParameter.php |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | namespace netfocusinc\argh; |
| 8 | 8 | |
@@ -11,16 +11,16 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * A Integer Parameter. |
|
| 15 | - * |
|
| 16 | - * Subtype of Parameter that represents an integer. |
|
| 17 | - * |
|
| 18 | - * @author Benjamin Hough |
|
| 19 | - * |
|
| 20 | - * @api |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - */ |
|
| 14 | + * A Integer Parameter. |
|
| 15 | + * |
|
| 16 | + * Subtype of Parameter that represents an integer. |
|
| 17 | + * |
|
| 18 | + * @author Benjamin Hough |
|
| 19 | + * |
|
| 20 | + * @api |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + */ |
|
| 24 | 24 | class IntegerParameter extends Parameter |
| 25 | 25 | { |
| 26 | 26 | |
@@ -33,26 +33,26 @@ discard block |
||
| 33 | 33 | // |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * Returns one of the ARGH_TYPE_INT |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * |
|
| 40 | - * @return int |
|
| 41 | - */ |
|
| 36 | + * Returns one of the ARGH_TYPE_INT |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * |
|
| 40 | + * @return int |
|
| 41 | + */ |
|
| 42 | 42 | public function getParameterType(): int |
| 43 | 43 | { |
| 44 | 44 | return Parameter::ARGH_TYPE_INT; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Sets the int value of this Parameter. |
|
| 49 | - * |
|
| 50 | - * Casts all values to int. |
|
| 51 | - * |
|
| 52 | - * @since 1.0.0 |
|
| 53 | - * |
|
| 54 | - * @return int |
|
| 55 | - */ |
|
| 48 | + * Sets the int value of this Parameter. |
|
| 49 | + * |
|
| 50 | + * Casts all values to int. |
|
| 51 | + * |
|
| 52 | + * @since 1.0.0 |
|
| 53 | + * |
|
| 54 | + * @return int |
|
| 55 | + */ |
|
| 56 | 56 | public function setValue($value) |
| 57 | 57 | { |
| 58 | 58 | if(!is_numeric($value)) |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Argh.php |
|
| 5 | - */ |
|
| 4 | + * Argh.php |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | namespace netfocusinc\argh; |
| 8 | 8 | |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | define('ARGH_TYPE_VARIABLE', Parameter::ARGH_TYPE_VARIABLE, true); |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Argument Helper |
|
| 22 | - * |
|
| 23 | - * The main class to be used by clients for parsing command line arguments. |
|
| 24 | - * |
|
| 25 | - * @api |
|
| 26 | - * |
|
| 27 | - * @author Benjamin Hough - Net Focus, Inc. |
|
| 28 | - * |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - * |
|
| 31 | - */ |
|
| 21 | + * Argument Helper |
|
| 22 | + * |
|
| 23 | + * The main class to be used by clients for parsing command line arguments. |
|
| 24 | + * |
|
| 25 | + * @api |
|
| 26 | + * |
|
| 27 | + * @author Benjamin Hough - Net Focus, Inc. |
|
| 28 | + * |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + * |
|
| 31 | + */ |
|
| 32 | 32 | class Argh |
| 33 | 33 | { |
| 34 | 34 | |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | // |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Create a new Argh instance and parses the arguments from $argv array |
|
| 54 | - * |
|
| 55 | - * This convenience method accepts both the PHP $argv array, and an array of Parameters used to interpret them. |
|
| 56 | - * After creating a new instance of Argh, the $argv array is interpreted against the specificed Parameters. |
|
| 57 | - * |
|
| 58 | - * @api |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * |
|
| 62 | - * @param array $argv |
|
| 63 | - * @param array $parameters Array of Parameters |
|
| 64 | - * |
|
| 65 | - * @return Argh |
|
| 66 | - */ |
|
| 53 | + * Create a new Argh instance and parses the arguments from $argv array |
|
| 54 | + * |
|
| 55 | + * This convenience method accepts both the PHP $argv array, and an array of Parameters used to interpret them. |
|
| 56 | + * After creating a new instance of Argh, the $argv array is interpreted against the specificed Parameters. |
|
| 57 | + * |
|
| 58 | + * @api |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * |
|
| 62 | + * @param array $argv |
|
| 63 | + * @param array $parameters Array of Parameters |
|
| 64 | + * |
|
| 65 | + * @return Argh |
|
| 66 | + */ |
|
| 67 | 67 | public static function parse(array $argv, array $parameters) : Argh |
| 68 | 68 | { |
| 69 | 69 | $argh = new Argh($parameters); |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * Create a new Argh instance and parses the arguments from $args string |
|
| 78 | - * |
|
| 79 | - * This convenience method accepts both a string of command line arguments, and an array of Parameters used to interpret them. |
|
| 80 | - * After creating a new instance of Argh, the $args string is interpreted against the specified Parameters. |
|
| 81 | - * |
|
| 82 | - * @api |
|
| 83 | - * |
|
| 84 | - * @since 1.0.0 |
|
| 85 | - * |
|
| 86 | - * @param string $args A string simulating command line entry |
|
| 87 | - * @param array $parameters Array of Parameters |
|
| 88 | - * |
|
| 89 | - * @return Argh |
|
| 90 | - */ |
|
| 77 | + * Create a new Argh instance and parses the arguments from $args string |
|
| 78 | + * |
|
| 79 | + * This convenience method accepts both a string of command line arguments, and an array of Parameters used to interpret them. |
|
| 80 | + * After creating a new instance of Argh, the $args string is interpreted against the specified Parameters. |
|
| 81 | + * |
|
| 82 | + * @api |
|
| 83 | + * |
|
| 84 | + * @since 1.0.0 |
|
| 85 | + * |
|
| 86 | + * @param string $args A string simulating command line entry |
|
| 87 | + * @param array $parameters Array of Parameters |
|
| 88 | + * |
|
| 89 | + * @return Argh |
|
| 90 | + */ |
|
| 91 | 91 | public static function parseString(string $args, array $parameters) : Argh |
| 92 | 92 | { |
| 93 | 93 | // Force $args into an array |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | // |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * Magic method providing access to parameter values via object properties syntax |
|
| 111 | - * |
|
| 112 | - * Forward requests for undefined object properties to Argh->get() method |
|
| 113 | - * |
|
| 114 | - * @internal |
|
| 115 | - * @since 1.0.0 |
|
| 116 | - * |
|
| 117 | - * @param string $name The name (or flag) of a defined Parameter |
|
| 118 | - * |
|
| 119 | - * @return mixed The value of a Parameter (type depends on the Parameter's type) |
|
| 120 | - */ |
|
| 110 | + * Magic method providing access to parameter values via object properties syntax |
|
| 111 | + * |
|
| 112 | + * Forward requests for undefined object properties to Argh->get() method |
|
| 113 | + * |
|
| 114 | + * @internal |
|
| 115 | + * @since 1.0.0 |
|
| 116 | + * |
|
| 117 | + * @param string $name The name (or flag) of a defined Parameter |
|
| 118 | + * |
|
| 119 | + * @return mixed The value of a Parameter (type depends on the Parameter's type) |
|
| 120 | + */ |
|
| 121 | 121 | public function __get(string $key) |
| 122 | 122 | { |
| 123 | 123 | // Get parameters from this instance |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * Magic method checks if a parameter value has been set via object property syntax |
|
| 129 | - * |
|
| 130 | - * @internal |
|
| 131 | - * @since 1.0.0 |
|
| 132 | - * |
|
| 133 | - * @param string $key The name (of flag) of a parameter |
|
| 134 | - * |
|
| 135 | - * @return boolean TRUE when the named parameter exists, otherwise FALSE |
|
| 136 | - */ |
|
| 128 | + * Magic method checks if a parameter value has been set via object property syntax |
|
| 129 | + * |
|
| 130 | + * @internal |
|
| 131 | + * @since 1.0.0 |
|
| 132 | + * |
|
| 133 | + * @param string $key The name (of flag) of a parameter |
|
| 134 | + * |
|
| 135 | + * @return boolean TRUE when the named parameter exists, otherwise FALSE |
|
| 136 | + */ |
|
| 137 | 137 | public function __isset(string $key): bool |
| 138 | 138 | { |
| 139 | 139 | if( $this->parameters->exists($key) ) |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | // |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * Contructs a new Argh instance |
|
| 155 | - * |
|
| 156 | - * Constructs a new instance of Argh with the specified Parameters. |
|
| 157 | - * The resulting Argh instance is ready to interpret command line arguments. |
|
| 158 | - * It is usually preferred to use Argh:parse() to create new Argh instances. |
|
| 159 | - * Direct contruction is only necessary if you want to re-use the same Argh instance |
|
| 160 | - * for parsing multiple sets of command line arguments. |
|
| 161 | - * |
|
| 162 | - * @api |
|
| 163 | - * |
|
| 164 | - * @since 1.0.0 |
|
| 165 | - * |
|
| 166 | - * @param array $parameters An array of Parameters to use for interpreting command line arguments |
|
| 167 | - * |
|
| 168 | - */ |
|
| 154 | + * Contructs a new Argh instance |
|
| 155 | + * |
|
| 156 | + * Constructs a new instance of Argh with the specified Parameters. |
|
| 157 | + * The resulting Argh instance is ready to interpret command line arguments. |
|
| 158 | + * It is usually preferred to use Argh:parse() to create new Argh instances. |
|
| 159 | + * Direct contruction is only necessary if you want to re-use the same Argh instance |
|
| 160 | + * for parsing multiple sets of command line arguments. |
|
| 161 | + * |
|
| 162 | + * @api |
|
| 163 | + * |
|
| 164 | + * @since 1.0.0 |
|
| 165 | + * |
|
| 166 | + * @param array $parameters An array of Parameters to use for interpreting command line arguments |
|
| 167 | + * |
|
| 168 | + */ |
|
| 169 | 169 | public function __construct(array $parameters) |
| 170 | 170 | { |
| 171 | 171 | // Init Language |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | } // END: public function __construct() |
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | - * Interprets an array of command line arguments |
|
| 187 | - * |
|
| 188 | - * Parses the given $argv array using this instances pre-defined set of Parameters |
|
| 189 | - * |
|
| 190 | - * @api |
|
| 191 | - * |
|
| 192 | - * @since 1.0.0 |
|
| 193 | - * |
|
| 194 | - * @param array $argv An array of command line arguments to interpret |
|
| 195 | - * |
|
| 196 | - * @throws ArghException |
|
| 197 | - */ |
|
| 186 | + * Interprets an array of command line arguments |
|
| 187 | + * |
|
| 188 | + * Parses the given $argv array using this instances pre-defined set of Parameters |
|
| 189 | + * |
|
| 190 | + * @api |
|
| 191 | + * |
|
| 192 | + * @since 1.0.0 |
|
| 193 | + * |
|
| 194 | + * @param array $argv An array of command line arguments to interpret |
|
| 195 | + * |
|
| 196 | + * @throws ArghException |
|
| 197 | + */ |
|
| 198 | 198 | public function parseArguments(array $argv) |
| 199 | 199 | { |
| 200 | 200 | // Set properties on this object |
@@ -221,19 +221,19 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * Access elements of the original $argv array |
|
| 225 | - * |
|
| 226 | - * Provides access to the $argv array (and its elements) as registered by PHP CLI |
|
| 227 | - * |
|
| 228 | - * @api |
|
| 229 | - * |
|
| 230 | - * @since 1.0.0 |
|
| 231 | - * |
|
| 232 | - * @param int|null $i The index of an $argv element; or null to return the entire $argv array |
|
| 233 | - * |
|
| 234 | - * @return mixed The value of an element of the $argv array; or the entire $argv array (when param $i is null) |
|
| 235 | - * @throws ArghException if $i is not a valid index of $argv |
|
| 236 | - */ |
|
| 224 | + * Access elements of the original $argv array |
|
| 225 | + * |
|
| 226 | + * Provides access to the $argv array (and its elements) as registered by PHP CLI |
|
| 227 | + * |
|
| 228 | + * @api |
|
| 229 | + * |
|
| 230 | + * @since 1.0.0 |
|
| 231 | + * |
|
| 232 | + * @param int|null $i The index of an $argv element; or null to return the entire $argv array |
|
| 233 | + * |
|
| 234 | + * @return mixed The value of an element of the $argv array; or the entire $argv array (when param $i is null) |
|
| 235 | + * @throws ArghException if $i is not a valid index of $argv |
|
| 236 | + */ |
|
| 237 | 237 | public function argv(int $i=null) |
| 238 | 238 | { |
| 239 | 239 | if($i !== null) |
@@ -254,21 +254,21 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | - * Retrieves the value of a defined Parameter. |
|
| 258 | - * |
|
| 259 | - * Find the value of an Parameter |
|
| 260 | - * Either the value of an Argument, if supplied on the command line, |
|
| 261 | - * or, the default value as defined by the arguments corresponding Parameter. |
|
| 262 | - * |
|
| 263 | - * @api |
|
| 264 | - * |
|
| 265 | - * @since 1.0.0 |
|
| 266 | - * |
|
| 267 | - * @param string $key The name (or flag) of a defined Parameter |
|
| 268 | - * |
|
| 269 | - * @return mixed The value of a Parameter (type depends on the Parameter's type) |
|
| 270 | - * @throws ArghException if the $key is not the name of a defined Parameter. |
|
| 271 | - */ |
|
| 257 | + * Retrieves the value of a defined Parameter. |
|
| 258 | + * |
|
| 259 | + * Find the value of an Parameter |
|
| 260 | + * Either the value of an Argument, if supplied on the command line, |
|
| 261 | + * or, the default value as defined by the arguments corresponding Parameter. |
|
| 262 | + * |
|
| 263 | + * @api |
|
| 264 | + * |
|
| 265 | + * @since 1.0.0 |
|
| 266 | + * |
|
| 267 | + * @param string $key The name (or flag) of a defined Parameter |
|
| 268 | + * |
|
| 269 | + * @return mixed The value of a Parameter (type depends on the Parameter's type) |
|
| 270 | + * @throws ArghException if the $key is not the name of a defined Parameter. |
|
| 271 | + */ |
|
| 272 | 272 | public function get($key) |
| 273 | 273 | { |
| 274 | 274 | |
@@ -295,21 +295,21 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | - * Retrieves any (unmarked) variables that were supplied as command line arguments. |
|
| 299 | - * |
|
| 300 | - * Variables are a type of Parameter that are unmarked (they have no name or flag). |
|
| 301 | - * To parse variables, a VariableParameter must be added when creating a new Argh instance. |
|
| 302 | - * This function is used to retrieve unmarked variables supplied as command line arguments. |
|
| 303 | - * Any variables will be returned as an array of values. |
|
| 304 | - * |
|
| 305 | - * @api |
|
| 306 | - * |
|
| 307 | - * @since 1.0.0 |
|
| 308 | - * |
|
| 309 | - * @param string $key The name (or flag) of a defined Parameter |
|
| 310 | - * |
|
| 311 | - * @return mixed An array of strings when variables are present, otherwise FALSE |
|
| 312 | - */ |
|
| 298 | + * Retrieves any (unmarked) variables that were supplied as command line arguments. |
|
| 299 | + * |
|
| 300 | + * Variables are a type of Parameter that are unmarked (they have no name or flag). |
|
| 301 | + * To parse variables, a VariableParameter must be added when creating a new Argh instance. |
|
| 302 | + * This function is used to retrieve unmarked variables supplied as command line arguments. |
|
| 303 | + * Any variables will be returned as an array of values. |
|
| 304 | + * |
|
| 305 | + * @api |
|
| 306 | + * |
|
| 307 | + * @since 1.0.0 |
|
| 308 | + * |
|
| 309 | + * @param string $key The name (or flag) of a defined Parameter |
|
| 310 | + * |
|
| 311 | + * @return mixed An array of strings when variables are present, otherwise FALSE |
|
| 312 | + */ |
|
| 313 | 313 | public function variables() |
| 314 | 314 | { |
| 315 | 315 | if($this->parameters->hasVariable()) |
@@ -322,37 +322,37 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
| 325 | - * Retrieves the ParameterCollection maintained by this Argh instance. |
|
| 326 | - * |
|
| 327 | - * Variables are a type of Parameter that are unmarked (they have no name or flag). |
|
| 328 | - * To parse variables, a VariableParameter must be added when creating a new Argh instance. |
|
| 329 | - * This function is used to retrieve unmarked variables supplied as command line arguments. |
|
| 330 | - * Any variables will be returned as an array of values. |
|
| 331 | - * |
|
| 332 | - * @api |
|
| 333 | - * |
|
| 334 | - * @since 1.0.0 |
|
| 335 | - * |
|
| 336 | - * @param string $key The name (or flag) of a defined Parameter |
|
| 337 | - * |
|
| 338 | - * @return ParameterCollection A collection of Parameters maintained by Argh |
|
| 339 | - */ |
|
| 325 | + * Retrieves the ParameterCollection maintained by this Argh instance. |
|
| 326 | + * |
|
| 327 | + * Variables are a type of Parameter that are unmarked (they have no name or flag). |
|
| 328 | + * To parse variables, a VariableParameter must be added when creating a new Argh instance. |
|
| 329 | + * This function is used to retrieve unmarked variables supplied as command line arguments. |
|
| 330 | + * Any variables will be returned as an array of values. |
|
| 331 | + * |
|
| 332 | + * @api |
|
| 333 | + * |
|
| 334 | + * @since 1.0.0 |
|
| 335 | + * |
|
| 336 | + * @param string $key The name (or flag) of a defined Parameter |
|
| 337 | + * |
|
| 338 | + * @return ParameterCollection A collection of Parameters maintained by Argh |
|
| 339 | + */ |
|
| 340 | 340 | public function parameters() : ParameterCollection { return $this->parameters; } |
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | - * Creates a 'usage string' useful for describing the command line arguments accepted by your program. |
|
| 344 | - * |
|
| 345 | - * This method can be used to create a string of descriptive text that details the command line arguments your |
|
| 346 | - * program accepts. This can be displayed to users when your program is invoked with a 'help' flag, or |
|
| 347 | - * when invalid command line arguments are used. |
|
| 348 | - * |
|
| 349 | - * @api |
|
| 350 | - * |
|
| 351 | - * @since 1.0.0 |
|
| 352 | - * |
|
| 353 | - * |
|
| 354 | - * @return string Descriptive text that details the command line arguments accepted by your program. |
|
| 355 | - */ |
|
| 343 | + * Creates a 'usage string' useful for describing the command line arguments accepted by your program. |
|
| 344 | + * |
|
| 345 | + * This method can be used to create a string of descriptive text that details the command line arguments your |
|
| 346 | + * program accepts. This can be displayed to users when your program is invoked with a 'help' flag, or |
|
| 347 | + * when invalid command line arguments are used. |
|
| 348 | + * |
|
| 349 | + * @api |
|
| 350 | + * |
|
| 351 | + * @since 1.0.0 |
|
| 352 | + * |
|
| 353 | + * |
|
| 354 | + * @return string Descriptive text that details the command line arguments accepted by your program. |
|
| 355 | + */ |
|
| 356 | 356 | public function usageString() |
| 357 | 357 | { |
| 358 | 358 | //! TODO: Accept a formatting string/array (e.g. ['-f', '--name', 'text']) |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * An alias of function usage() |
|
| 413 | - * |
|
| 414 | - * @api |
|
| 415 | - * |
|
| 416 | - * @since 1.0.0 |
|
| 417 | - * |
|
| 418 | - * @return string Descriptive text that details the command line arguments accepted by your program. |
|
| 419 | - */ |
|
| 412 | + * An alias of function usage() |
|
| 413 | + * |
|
| 414 | + * @api |
|
| 415 | + * |
|
| 416 | + * @since 1.0.0 |
|
| 417 | + * |
|
| 418 | + * @return string Descriptive text that details the command line arguments accepted by your program. |
|
| 419 | + */ |
|
| 420 | 420 | public function usage() { return $this->usageString(); } |
| 421 | 421 | |
| 422 | 422 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Language.php |
|
| 5 | - */ |
|
| 4 | + * Language.php |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | namespace netfocusinc\argh; |
| 8 | 8 | |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | define('ARGH_SEMANTICS_VARIABLE', Rule::ARGH_SEMANTICS_VARIABLE, true); |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * Langugage is a set of Rules (with Syntax and Semantics) used to interpret command line arguments. |
|
| 34 | - * |
|
| 35 | - * The Language class manages the Rules used to interpret command line arguments during parsing. |
|
| 36 | - * This class is a container for Rules, and features convenience methods for constructing a language complete with a set of standard rules. |
|
| 37 | - * |
|
| 38 | - * @api |
|
| 39 | - * |
|
| 40 | - * @author Benjamin Hough |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - */ |
|
| 33 | + * Langugage is a set of Rules (with Syntax and Semantics) used to interpret command line arguments. |
|
| 34 | + * |
|
| 35 | + * The Language class manages the Rules used to interpret command line arguments during parsing. |
|
| 36 | + * This class is a container for Rules, and features convenience methods for constructing a language complete with a set of standard rules. |
|
| 37 | + * |
|
| 38 | + * @api |
|
| 39 | + * |
|
| 40 | + * @author Benjamin Hough |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + */ |
|
| 44 | 44 | class Language |
| 45 | 45 | { |
| 46 | 46 | |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | // |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Creates a Language, complete with a set of Rules used for interpreting command line arguments |
|
| 60 | - * |
|
| 61 | - * This is the main function to use when creating a new Langugage. |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * |
|
| 65 | - * @return Language |
|
| 66 | - */ |
|
| 59 | + * Creates a Language, complete with a set of Rules used for interpreting command line arguments |
|
| 60 | + * |
|
| 61 | + * This is the main function to use when creating a new Langugage. |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * |
|
| 65 | + * @return Language |
|
| 66 | + */ |
|
| 67 | 67 | public static function createWithRules() |
| 68 | 68 | { |
| 69 | 69 | // Create a new Language instance |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | // |
| 239 | 239 | |
| 240 | 240 | /** |
| 241 | - * Langugage Constructor |
|
| 242 | - * |
|
| 243 | - * The preferred way of constructing a new Language, is with the static createWithRules() method. |
|
| 244 | - * This constructor is useful for creating custom languages, with non-standard rule sets. |
|
| 245 | - * |
|
| 246 | - * @since 1.0.0 |
|
| 247 | - * |
|
| 248 | - * @throws Exception |
|
| 249 | - */ |
|
| 241 | + * Langugage Constructor |
|
| 242 | + * |
|
| 243 | + * The preferred way of constructing a new Language, is with the static createWithRules() method. |
|
| 244 | + * This constructor is useful for creating custom languages, with non-standard rule sets. |
|
| 245 | + * |
|
| 246 | + * @since 1.0.0 |
|
| 247 | + * |
|
| 248 | + * @throws Exception |
|
| 249 | + */ |
|
| 250 | 250 | public function __construct() |
| 251 | 251 | { |
| 252 | 252 | try |
@@ -262,24 +262,24 @@ discard block |
||
| 262 | 262 | } // END: __construct() |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Returns the set of Rules maintained by this Language. |
|
| 266 | - * |
|
| 267 | - * @since 1.0.0 |
|
| 268 | - * |
|
| 269 | - * @return array An array of Rules |
|
| 270 | - */ |
|
| 265 | + * Returns the set of Rules maintained by this Language. |
|
| 266 | + * |
|
| 267 | + * @since 1.0.0 |
|
| 268 | + * |
|
| 269 | + * @return array An array of Rules |
|
| 270 | + */ |
|
| 271 | 271 | public function rules() |
| 272 | 272 | { |
| 273 | 273 | return $this->rules; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Adds a Rule to the set of rules maintained by this Language. |
|
| 278 | - * |
|
| 279 | - * @since 1.0.0 |
|
| 280 | - * |
|
| 281 | - * @param $rule Rule |
|
| 282 | - */ |
|
| 277 | + * Adds a Rule to the set of rules maintained by this Language. |
|
| 278 | + * |
|
| 279 | + * @since 1.0.0 |
|
| 280 | + * |
|
| 281 | + * @param $rule Rule |
|
| 282 | + */ |
|
| 283 | 283 | public function addRule(Rule $rule) |
| 284 | 284 | { |
| 285 | 285 | $this->rules[] = $rule; |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * VariableParameter.php |
|
| 5 | - */ |
|
| 4 | + * VariableParameter.php |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | namespace netfocusinc\argh; |
| 8 | 8 | |
@@ -10,18 +10,18 @@ discard block |
||
| 10 | 10 | use netfocusinc\argh\Parameter; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Variable parameter. |
|
| 14 | - * |
|
| 15 | - * Subtype of Parameter that represents an (unmarked) variable. |
|
| 16 | - * Variable Parameters are used to save unmakred input (naked variables) |
|
| 17 | - * Their value always consists of an array. |
|
| 18 | - * |
|
| 19 | - * @api |
|
| 20 | - * |
|
| 21 | - * @author Benjamin Hough |
|
| 22 | - * |
|
| 23 | - * @since 1.0.0 |
|
| 24 | - */ |
|
| 13 | + * Variable parameter. |
|
| 14 | + * |
|
| 15 | + * Subtype of Parameter that represents an (unmarked) variable. |
|
| 16 | + * Variable Parameters are used to save unmakred input (naked variables) |
|
| 17 | + * Their value always consists of an array. |
|
| 18 | + * |
|
| 19 | + * @api |
|
| 20 | + * |
|
| 21 | + * @author Benjamin Hough |
|
| 22 | + * |
|
| 23 | + * @since 1.0.0 |
|
| 24 | + */ |
|
| 25 | 25 | class VariableParameter extends Parameter |
| 26 | 26 | { |
| 27 | 27 | |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | // |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * Returns an instance of VariableParameter |
|
| 34 | - * |
|
| 35 | - * VariableParameters are always named with the ARGH_NAME_VARIABLE constant |
|
| 36 | - * |
|
| 37 | - * @since 1.0.1 |
|
| 38 | - * |
|
| 39 | - * @return Parameter |
|
| 40 | - */ |
|
| 33 | + * Returns an instance of VariableParameter |
|
| 34 | + * |
|
| 35 | + * VariableParameters are always named with the ARGH_NAME_VARIABLE constant |
|
| 36 | + * |
|
| 37 | + * @since 1.0.1 |
|
| 38 | + * |
|
| 39 | + * @return Parameter |
|
| 40 | + */ |
|
| 41 | 41 | public static function create() : Parameter |
| 42 | 42 | { |
| 43 | 43 | return parent::createWithAttributes( |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Returns an instance of VariableParameter |
|
| 54 | - * |
|
| 55 | - * Overriding Parameter::createWithAttribute() here prevents this from being called with a custom 'name' attribute |
|
| 56 | - * VariableParameters need to be named with ARGH_NAME_VARIABLE constant; Argh uses this 'name' to find variables |
|
| 57 | - * |
|
| 58 | - * @since 1.0.2 |
|
| 59 | - * |
|
| 60 | - * @param array $attributes |
|
| 61 | - * |
|
| 62 | - * @return Parameter |
|
| 63 | - */ |
|
| 53 | + * Returns an instance of VariableParameter |
|
| 54 | + * |
|
| 55 | + * Overriding Parameter::createWithAttribute() here prevents this from being called with a custom 'name' attribute |
|
| 56 | + * VariableParameters need to be named with ARGH_NAME_VARIABLE constant; Argh uses this 'name' to find variables |
|
| 57 | + * |
|
| 58 | + * @since 1.0.2 |
|
| 59 | + * |
|
| 60 | + * @param array $attributes |
|
| 61 | + * |
|
| 62 | + * @return Parameter |
|
| 63 | + */ |
|
| 64 | 64 | public static function createWithAttributes(array $attributes) : Parameter |
| 65 | 65 | { |
| 66 | 66 | // Force VariableParameters to use a constant name |
@@ -77,26 +77,26 @@ discard block |
||
| 77 | 77 | // |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * Returns ARGH_TYPE_VARIABLE |
|
| 81 | - * |
|
| 82 | - * @since 1.0.0 |
|
| 83 | - * |
|
| 84 | - * @return int |
|
| 85 | - */ |
|
| 80 | + * Returns ARGH_TYPE_VARIABLE |
|
| 81 | + * |
|
| 82 | + * @since 1.0.0 |
|
| 83 | + * |
|
| 84 | + * @return int |
|
| 85 | + */ |
|
| 86 | 86 | public function getParameterType(): int |
| 87 | 87 | { |
| 88 | 88 | return Parameter::ARGH_TYPE_VARIABLE; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * Sets the array value of this Parameter. |
|
| 93 | - * |
|
| 94 | - * Forces all values into an array |
|
| 95 | - * |
|
| 96 | - * @since 1.0.0 |
|
| 97 | - * |
|
| 98 | - * @param mixed $value |
|
| 99 | - */ |
|
| 92 | + * Sets the array value of this Parameter. |
|
| 93 | + * |
|
| 94 | + * Forces all values into an array |
|
| 95 | + * |
|
| 96 | + * @since 1.0.0 |
|
| 97 | + * |
|
| 98 | + * @param mixed $value |
|
| 99 | + */ |
|
| 100 | 100 | public function setValue($value) |
| 101 | 101 | { |
| 102 | 102 | if(is_array($value)) |
@@ -110,15 +110,15 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * Adds an element to the value of this Parameter |
|
| 114 | - * |
|
| 115 | - * Forces all values into an array |
|
| 116 | - * |
|
| 117 | - * @since 1.0.0 |
|
| 118 | - * |
|
| 119 | - * @param mixed $value |
|
| 120 | - * |
|
| 121 | - */ |
|
| 113 | + * Adds an element to the value of this Parameter |
|
| 114 | + * |
|
| 115 | + * Forces all values into an array |
|
| 116 | + * |
|
| 117 | + * @since 1.0.0 |
|
| 118 | + * |
|
| 119 | + * @param mixed $value |
|
| 120 | + * |
|
| 121 | + */ |
|
| 122 | 122 | public function addValue($value) |
| 123 | 123 | { |
| 124 | 124 | // Check if this Parameter has a previously set value |
@@ -1,51 +1,51 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * ArghException.php |
|
| 5 | - */ |
|
| 4 | + * ArghException.php |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | namespace netfocusinc\argh; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * An exception that is thrown by Argh |
|
| 11 | - * |
|
| 12 | - * A subclass of Exception that is thrown by Argh. |
|
| 13 | - * |
|
| 14 | - * @author Benjamin Hough |
|
| 15 | - * |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - * |
|
| 18 | - */ |
|
| 10 | + * An exception that is thrown by Argh |
|
| 11 | + * |
|
| 12 | + * A subclass of Exception that is thrown by Argh. |
|
| 13 | + * |
|
| 14 | + * @author Benjamin Hough |
|
| 15 | + * |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | 19 | class ArghException extends \Exception |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * Contruct a new ArghException with a required message |
|
| 23 | - * |
|
| 24 | - * @since 1.0.0 |
|
| 25 | - * |
|
| 26 | - * @param string $message Custom message describing this Exception |
|
| 27 | - * @param int $code Custom error code |
|
| 28 | - * @param Exception $previous The previous Exception to occurr |
|
| 29 | - * |
|
| 30 | - */ |
|
| 31 | - public function __construct($message, $code = 0, \Exception $previous = null) { |
|
| 32 | - // some code |
|
| 22 | + * Contruct a new ArghException with a required message |
|
| 23 | + * |
|
| 24 | + * @since 1.0.0 |
|
| 25 | + * |
|
| 26 | + * @param string $message Custom message describing this Exception |
|
| 27 | + * @param int $code Custom error code |
|
| 28 | + * @param Exception $previous The previous Exception to occurr |
|
| 29 | + * |
|
| 30 | + */ |
|
| 31 | + public function __construct($message, $code = 0, \Exception $previous = null) { |
|
| 32 | + // some code |
|
| 33 | 33 | |
| 34 | - // make sure everything is assigned properly |
|
| 35 | - parent::__construct($message, $code, $previous); |
|
| 36 | - } |
|
| 34 | + // make sure everything is assigned properly |
|
| 35 | + parent::__construct($message, $code, $previous); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * Returns a descriptive string indentifying this Exception |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * |
|
| 44 | - * @return string |
|
| 45 | - * |
|
| 46 | - */ |
|
| 47 | - public function __toString() { |
|
| 48 | - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
| 49 | - } |
|
| 40 | + * Returns a descriptive string indentifying this Exception |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * |
|
| 44 | + * @return string |
|
| 45 | + * |
|
| 46 | + */ |
|
| 47 | + public function __toString() { |
|
| 48 | + return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |