Option

class Option

An option

Copyright
2016 Appertly contributors
License
MIT

Constructors / Destructors

Public
ReturnsSignature and Description
void
__construct(string $spec, string $description)

Creates a new Option

Instance Methods

Public
ReturnsSignature and Description
string

Gets the option description.

ImmSet<string>

Gets the option long aliases

ImmSet<string>

Gets the option short aliases.

string

Gets the option type.

bool

Whether the option is incremental

bool

Whether the option can be used multiple times

bool

Whether the option can take a value

bool

Whether the option requires a value

bool

Whether the option takes no value

mixed
parse(mixed $value)

Parses an incoming value based on the type defined

Method Details

__construct

public function __construct(string $spec, string $description)

Creates a new Option

Parameters
NameTypeDescription
$specstring

The option specification

$descriptionstring

A human readable description

getDescription

public function getDescription()

Gets the option description.

Returns
TypeDescription
string

The description

getLongs

public function getLongs()

Gets the option long aliases

Returns
TypeDescription
ImmSet<string>

The long aliases

getShorts

public function getShorts()

Gets the option short aliases.

Returns
TypeDescription
ImmSet<string>

The short aliases

getType

public function getType()

Gets the option type.

Returns
TypeDescription
string

The type: s, i, f, d

isIncremental

public function isIncremental()

Whether the option is incremental

Returns
TypeDescription
bool

the option incremental

isMultiple

public function isMultiple()

Whether the option can be used multiple times

Returns
TypeDescription
bool

true if the option is multiple

isOptional

public function isOptional()

Whether the option can take a value

Returns
TypeDescription
bool

true if the option can take a value

isRequired

public function isRequired()

Whether the option requires a value

Returns
TypeDescription
bool

true if the option requires a value

isSolo

public function isSolo()

Whether the option takes no value

Returns
TypeDescription
bool

true if the option takes no value

parse

public function parse(mixed $value)

Parses an incoming value based on the type defined

Parameters
NameTypeDescription
$valuemixed

The incoming value

Returns
TypeDescription
mixed

The converted value