Overview

Namespaces

  • None
  • Peg
    • Cli
      • Commands
    • Config
    • Custom
      • Command
        • Action
          • Generate
          • Parse
      • CommandLine
      • Config
      • Localization
      • Utilities
    • Lib
      • Definitions
        • Element
      • Generator
      • Lexers
      • Plugins
      • Signals
        • Data
          • Definitions
          • Lexers
        • Type
  • PHP

Classes

  • Action
  • Command
  • Error
  • Option
  • OptionType
  • Parser
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

Class Option

Represents a command line option.

Namespace: Peg\Custom\CommandLine
Located at src/CommandLine/Option.php
Methods summary
public
# __construct( array $properties = null )

Initilize the option with an optional list of properties defined on an array.

Initilize the option with an optional list of properties defined on an array.

Parameters

$properties
array
$properties
public boolean
# IsValid( )

Checks if the option value is valid.

Checks if the option value is valid.

Returns

boolean
public integer|string
# GetValue( )

Automatically returns the current or default value or null if neither is set.

Automatically returns the current or default value or null if neither is set.

Returns

integer|string
public boolean
# SetValue( integer|string $value )

Useful to add a value while checking if the value isn't in fact another parameter like --other -o

Useful to add a value while checking if the value isn't in fact another parameter like --other -o

Parameters

$value
integer|string
$value

Returns

boolean
True if value was set otherwise false.
Properties summary
public string $long_name
#

The human readable name of the option. Example: --use-something stored on this variable as use-something.

The human readable name of the option. Example: --use-something stored on this variable as use-something.

public string $short_name
#

A one letter case-sensitive alias for the option. Example: -u stored on this variable as u.

A one letter case-sensitive alias for the option. Example: -u stored on this variable as u.

public integer $type
#

Data type of the option represented by one of the constants from \Peg\Custom\CommandLine\OptionType

Data type of the option represented by one of the constants from \Peg\Custom\CommandLine\OptionType

public integer|string $value
#

Current value of the option.

Current value of the option.

public integer|string $default_value
#

A default value used in case the user didn't provided one and the option isn't marked as required.

A default value used in case the user didn't provided one and the option isn't marked as required.

public boolean $active
#

Indicates if an option of type FLAG was passed on the command line.

Indicates if an option of type FLAG was passed on the command line.

public boolean $required
#

Flag that indicates if the option is required or not.

Flag that indicates if the option is required or not.

public string $description
#

Information displayed when the application is executed without options or with: -h, --help

Information displayed when the application is executed without options or with: -h, --help

PEG Api API documentation generated by ApiGen 2.8.0