Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
14 / 14 |
|
70.00% |
7 / 10 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Commands | |
100.00% |
12 / 12 |
|
100.00% |
14 / 14 |
|
70.00% |
7 / 10 |
|
100.00% |
4 / 4 |
9.73 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| add | |
100.00% |
9 / 9 |
|
100.00% |
11 / 11 |
|
57.14% |
4 / 7 |
|
100.00% |
1 / 1 |
6.97 | |||
| get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addCommand | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Cli; |
| 6 | |
| 7 | /** |
| 8 | * @api |
| 9 | */ |
| 10 | final class Commands |
| 11 | { |
| 12 | private array $commands = []; |
| 13 | |
| 14 | public function __construct(Command|array $commands = []) |
| 15 | { |
| 16 | $this->add($commands); |
| 17 | } |
| 18 | |
| 19 | public function add(Commands|Command|array $commands): void |
| 20 | { |
| 21 | if (is_array($commands)) { |
| 22 | foreach ($commands as $command) { |
| 23 | $this->add($command); |
| 24 | } |
| 25 | |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | if ($commands instanceof Commands) { |
| 30 | foreach ($commands->get() as $command) { |
| 31 | $this->addCommand($command); |
| 32 | } |
| 33 | |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | $this->addCommand($commands); |
| 38 | } |
| 39 | |
| 40 | public function get(): array |
| 41 | { |
| 42 | return $this->commands; |
| 43 | } |
| 44 | |
| 45 | private function addCommand(Command $command): void |
| 46 | { |
| 47 | $this->commands[] = $command; |
| 48 | } |
| 49 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 14 | public function __construct(Command|array $commands = []) |
| 15 | { |
| 16 | $this->add($commands); |
| 17 | } |
| 19 | public function add(Commands|Command|array $commands): void |
| 20 | { |
| 21 | if (is_array($commands)) { |
| 22 | foreach ($commands as $command) { |
| 22 | foreach ($commands as $command) { |
| 22 | foreach ($commands as $command) { |
| 23 | $this->add($command); |
| 22 | foreach ($commands as $command) { |
| 23 | $this->add($command); |
| 24 | } |
| 25 | |
| 26 | return; |
| 29 | if ($commands instanceof Commands) { |
| 30 | foreach ($commands->get() as $command) { |
| 30 | foreach ($commands->get() as $command) { |
| 30 | foreach ($commands->get() as $command) { |
| 31 | $this->addCommand($command); |
| 30 | foreach ($commands->get() as $command) { |
| 31 | $this->addCommand($command); |
| 32 | } |
| 33 | |
| 34 | return; |
| 37 | $this->addCommand($commands); |
| 38 | } |
| 45 | private function addCommand(Command $command): void |
| 46 | { |
| 47 | $this->commands[] = $command; |
| 48 | } |
| 42 | return $this->commands; |
| 43 | } |