| Total Complexity | 8 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Commands |
||
| 8 | { |
||
| 9 | protected array $commands = []; |
||
| 10 | |||
| 11 | 21 | public function __construct(Command|array $commands = []) |
|
| 12 | { |
||
| 13 | 21 | $this->add($commands); |
|
| 14 | } |
||
| 15 | |||
| 16 | 21 | public function add(Commands|Command|array $commands): void |
|
| 17 | { |
||
| 18 | 21 | if (is_array($commands)) { |
|
|
|
|||
| 19 | 19 | foreach ($commands as $command) { |
|
| 20 | 18 | $this->add($command); |
|
| 21 | } |
||
| 22 | 21 | } elseif ($commands instanceof Commands) { |
|
| 23 | 2 | foreach ($commands->get() as $command) { |
|
| 24 | 2 | $this->addCommand($command); |
|
| 25 | } |
||
| 26 | } else { |
||
| 27 | 21 | $this->addCommand($commands); |
|
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | 21 | public function get(): array |
|
| 34 | } |
||
| 35 | |||
| 36 | 21 | protected function addCommand(Command $command): void |
|
| 39 | } |
||
| 40 | } |
||
| 41 |