Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| DevTools | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDefaultCommands | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of fast-forward/dev-tools. |
| 7 | * |
| 8 | * This source file is subject to the license bundled |
| 9 | * with this source code in the file LICENSE. |
| 10 | * |
| 11 | * @copyright Copyright (c) 2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 12 | * @license https://opensource.org/licenses/MIT MIT License |
| 13 | * |
| 14 | * @see https://github.com/php-fast-forward/dev-tools |
| 15 | * @see https://github.com/php-fast-forward |
| 16 | * @see https://datatracker.ietf.org/doc/html/rfc2119 |
| 17 | */ |
| 18 | |
| 19 | namespace FastForward\DevTools; |
| 20 | |
| 21 | use Override; |
| 22 | use Composer\Console\Application; |
| 23 | use Composer\Plugin\Capability\CommandProvider; |
| 24 | use FastForward\DevTools\Composer\Capability\DevToolsCommandProvider; |
| 25 | use Symfony\Component\Console\Command\ListCommand; |
| 26 | use Symfony\Component\Console\Command\CompleteCommand; |
| 27 | use Symfony\Component\Console\Command\DumpCompletionCommand; |
| 28 | use Symfony\Component\Console\Command\HelpCommand; |
| 29 | |
| 30 | /** |
| 31 | * Wraps the fast-forward console tooling suite conceptually as an isolated application instance. |
| 32 | * Extending the base application, it MUST provide default command injections safely. |
| 33 | */ |
| 34 | final class DevTools extends Application |
| 35 | { |
| 36 | /** |
| 37 | * Initializes the DevTools global context and dependency graph. |
| 38 | * |
| 39 | * The method MUST define default configurations and MAY accept an explicit command provider. |
| 40 | * It SHALL instruct the runner to treat the `standards` command generically as its default endpoint. |
| 41 | * |
| 42 | * @param CommandProvider|null $commandProvider provides the execution references securely, defaults dynamically |
| 43 | */ |
| 44 | public function __construct( |
| 45 | private readonly ?CommandProvider $commandProvider = new DevToolsCommandProvider(), |
| 46 | ) { |
| 47 | parent::__construct('Fast Forward Dev Tools'); |
| 48 | $this->setDefaultCommand('standards'); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Aggregates default processes attached safely to the environment base lifecycle. |
| 53 | * |
| 54 | * The method MUST inject core operational constraints and external definitions seamlessly. |
| 55 | * It SHALL execute an overriding merge logically combining provider and utility features. |
| 56 | * |
| 57 | * @return array<int, mixed> the collected list of functional commands configured to run |
| 58 | */ |
| 59 | #[Override] |
| 60 | protected function getDefaultCommands(): array |
| 61 | { |
| 62 | return array_merge($this->commandProvider->getCommands(), [ |
| 63 | new HelpCommand(), |
| 64 | new ListCommand(), |
| 65 | new CompleteCommand(), |
| 66 | new DumpCompletionCommand(), |
| 67 | ]); |
| 68 | } |
| 69 | } |