| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Collector extends Args |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var Args |
||
| 19 | */ |
||
| 20 | private $args; |
||
| 21 | |||
| 22 | 3 | public function __construct(Args $args) |
|
| 25 | 3 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @param string|string[] $option one or more options to collect |
||
| 29 | * |
||
| 30 | * @throws \Ktomk\Pipelines\Cli\ArgsException |
||
| 31 | */ |
||
| 32 | 1 | public function collect($option) |
|
| 33 | { |
||
| 34 | /** @var OptionFilterIterator|OptionIterator $options */ |
||
| 35 | 1 | $options = new OptionFilterIterator($this->args, $option); |
|
| 36 | 1 | $consume = array(); |
|
| 37 | 1 | foreach ($options as $index => $option) { |
|
| 38 | 1 | $this->arguments[] = $option; |
|
| 39 | 1 | $consume[] = $index; |
|
| 40 | 1 | $this->arguments[] = $options->getArgument(); |
|
| 41 | 1 | $consume[] = $index + 1; |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | foreach ($consume as $index) { |
|
| 45 | 1 | unset($this->args->arguments[$index]); |
|
| 46 | } |
||
| 47 | 1 | } |
|
| 48 | |||
| 49 | /** |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | 1 | public function getArgs() |
|
| 55 | } |
||
| 56 | } |
||
| 57 |