webignition / symfony-console-typed-input
Symfony InputInterface providing type-specific getters for options and arguments
Installs: 1 460 967
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 2
Requires
- php: >=7.4|^8
- symfony/console: ^4.4|^5.0
Requires (Dev)
- mockery/mockery: ^1.4
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^0.12.77
- phpstan/phpstan-mockery: ^0.12.12
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
- symplify/easy-coding-standard: ^9.1
This package is auto-updated.
Last update: 2024-11-06 18:51:33 UTC
README
A wrapper for Symfony\Component\Console\Input\InputInterface
adding integer- and boolean-specific
argument and option getters.
For fans of strongly-typed PHP, or just those tired of battling with phpstan
--level max
when analysing Symfony console commands.
Methods
public function getIntegerArgument(string $name): int; public function getIntegerOption(string $name): int; public function getBooleanArgument(string $name): bool; public function getBooleanOption(string $name): bool;
All other InputInterface
method calls are proxied to the wrapped InputInterface
instance.
Usage
use webignition\SymfonyConsole\TypedInput\TypedInput; // Assuming we're in a console command and $input is an InputInterface instance $typedInput = new TypedInput($input); // Guaranteed to return an integer $integerArgument = $typedInput->getIntegerArgument('integer-argument-name'); $integerOption = $typedInput->getIntegerOption('integer-option-name'); // Guaranteed to return a boolean $booleanArgument = $typedInput->getBooleanArgument('boolean-argument-name'); $booleanOption = $typedInput->getBooleanOption('boolean-option-name');