Properties

$defaultNamespaces

$defaultNamespaces : 

Type

$commandLoader

$commandLoader : 

Type

$singleCommand

$singleCommand : 

Type

$defaultCommand

$defaultCommand : 

Type

$definition

$definition : 

Type

$isInitialized

$isInitialized : 

Type

$catchExceptions

$catchExceptions : 

Type

$terminal

$terminal : 

Type

Methods

__construct()

__construct() 

Kernel constructor.

has()

has(string  $name) : boolean

Returns true if the command exists, false otherwise.

Parameters

string $name

The command name or alias

Returns

boolean —

true if the command exists, false otherwise

get()

get(string  $name) : \app\framework\Component\Console\Command\Command

Returns a registered command by name or alias.

Parameters

string $name

The command name or alias

Throws

\app\framework\Component\Console\Exception\CommandNotFoundException

When given command name does not exist

Returns

\app\framework\Component\Console\Command\Command

A Command object

find()

find(string  $name) : \app\framework\Component\Console\Command\Command

Finds a command by name

Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias.

Parameters

string $name

A command name

Throws

\app\framework\Component\Console\Exception\CommandNotFoundException

When command name is incorrect or ambiguous

Returns

\app\framework\Component\Console\Command\Command

A Command instance

setCatchExceptions()

setCatchExceptions(boolean  $boolean) 

Sets whether to catch exceptions or not during commands execution.

Parameters

boolean $boolean

Whether to catch exceptions or not during commands execution

all()

all(string  $namespace = null) : array<mixed,\app\framework\Component\Console\Command\Command>

Gets the commands (registered in the given namespace if provided).

The array keys are the full names and the values the command instances.

Parameters

string $namespace

A namespace name

Returns

array<mixed,\app\framework\Component\Console\Command\Command> —

An array of Command instances

extractNamespace()

extractNamespace(string  $name, string  $limit = null) : string

Returns the namespace part of the command name.

This method is not part of public API and should not be used directly.

Parameters

string $name

The full name of the command

string $limit

The maximum number of parts of the namespace

Returns

string —

The namespace of the command

findNamespace()

findNamespace(string  $namespace) : string

Finds a registered namespace by a name or an abbreviation.

Parameters

string $namespace

A namespace or abbreviation to search for

Throws

\app\framework\Component\Console\Exception\NamespaceNotFoundException

When namespace is incorrect or ambiguous

Returns

string —

A registered namespace

getNamespaces()

getNamespaces() : array<mixed,string>

Returns an array of all unique namespaces used by currently registered commands.

It does not return the global namespace which always exists.

Returns

array<mixed,string> —

An array of namespaces

getLongVersion()

getLongVersion() : string

Returns the long version.

Returns

string —

The long application version

getHelp()

getHelp() : string

Gets the help message.

Returns

string —

A help message

init()

init() : void

If is not yet initialized add default commands.

extractAllNamespaces()

extractAllNamespaces(string  $name) : array<mixed,string>

Returns all namespaces of the command name.

Parameters

string $name

The full name of the command

Returns

array<mixed,string> —

The namespaces of the command

findAlternatives()

findAlternatives(string  $name, \app\framework\Component\Console\iterable  $collection) : array<mixed,string>

Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.

Parameters

string $name

The string

\app\framework\Component\Console\iterable $collection

The collection

Returns

array<mixed,string> —

A sorted array of similar string

splitStringByWidth()

splitStringByWidth(  $string,   $width) 

Parameters

$string
$width