final class CommandLineParser
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reads the arguments the command was invoked with.

Methods§

public function parse(list<string> $arguments): CommandLine

The command line the arguments describe.

Parameters

$argumentslist<string>The arguments, without the command name

Throws

InvalidCommandLineException When an argument is not one the command takes
InvalidConfigurationException When the catalog configuration is invalid
Test cases 15
Called from 1
Calls 8
public function configuration(?string $path): Configuration

Loads an explicit catalog file or the working directory's .catalog.yaml.

Parameters

$path?string

Throws

InvalidConfigurationException When the selected file cannot be loaded
Test cases 1
Called from 1
Calls 3
public function readOption(
    string $argument,
    list<string> $arguments,
    int $index,
    array<string, list<string>> &$values,
    array<string, bool> &$flags,
): int

Reads one option, consuming the argument after it when the option takes a value.

Parameters

$argumentstring
$argumentslist<string>
$indexint
$valuesarray<string, list<string>>
$flagsarray<string, bool>

Returns

int

Throws

InvalidCommandLineException When the option is unknown or its value is missing
Test cases 1
Called from 1
Calls 9
public function build(
    array<string, list<string>> $values,
    array<string, bool> $flags,
    list<string> $paths,
    Configuration $configuration = new \SqlCatalog\Facade\Configuration(),
): CommandLine

The command line built from the options that were read.

Parameters

$valuesarray<string, list<string>>
$flagsarray<string, bool>
$pathslist<string>
$configurationConfiguration

Throws

InvalidCommandLineException When an option was given a value it does not take
Test cases 3
Called from 1
Calls 7
public function filter(array<string, list<string>> $values): CatalogFilter

The filter the filtering options describe.

Parameters

$valuesarray<string, list<string>>

Throws

InvalidCommandLineException When a kind or severity is not one the command knows
Test cases 1
Called from 1
Calls 3
public function kinds(list<string> $written): list<StatementKind>

The statement kinds the written names stand for.

Parameters

$writtenlist<string>

Returns

Throws

InvalidCommandLineException When a name is not a statement kind
Test cases 2
Called from 1
Calls 7
public function severity(array<string, list<string>> $values, string $option): ?Severity

The severity an option was given, or null when it was not given.

Parameters

$valuesarray<string, list<string>>
$optionstring

Returns

Throws

InvalidCommandLineException When the name is not a severity
Test cases 2
Called from 2
Calls 8

Private surface 2§

Implementation details, listed for orientation only.

private const VALUE_OPTIONS = ['config' => 'config', 'c' => 'config', 'output' => 'output', 'o' => 'output', …
private const FLAG_OPTIONS = ['help' => 'help', 'h' => 'help', 'list-extensions' => 'list-extensions', 'list…

Test cases 27§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 26
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Method calls 1
Type declarations 1