Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
StandardsCommand
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(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
19namespace FastForward\DevTools\Command;
20
21use Symfony\Component\Console\Input\InputInterface;
22use Symfony\Component\Console\Input\InputOption;
23use Symfony\Component\Console\Output\OutputInterface;
24
25/**
26 * Executes the full suite of Fast Forward code standard checks.
27 * This class MUST NOT be modified through inheritance and SHALL streamline code validation workflows.
28 */
29final class StandardsCommand extends AbstractCommand
30{
31    /**
32     * Configures constraints and arguments for the collective standard runner.
33     *
34     * This method MUST specify definitions and help texts appropriately. It SHALL
35     * expose an optional `--fix` mode.
36     *
37     * @return void
38     */
39    protected function configure(): void
40    {
41        $this
42            ->setName('standards')
43            ->setDescription('Runs Fast Forward code standards checks.')
44            ->setHelp(
45                'This command runs all Fast Forward code standards checks, including code refactoring, '
46                . 'PHPDoc validation, code style checks, documentation generation, and tests execution.'
47            )
48            ->addOption(
49                name: 'fix',
50                shortcut: 'f',
51                mode: InputOption::VALUE_NONE,
52                description: 'Automatically fix code standards issues.'
53            );
54    }
55
56    /**
57     * Evaluates multiple commands seamlessly in a sequential execution.
58     *
59     * The method MUST trigger refactoring, phpdoc generation, code styling, and reports building block consecutively.
60     * It SHALL reliably return a standard SUCCESS execution state on completion.
61     *
62     * @param InputInterface $input internal input arguments retrieved via terminal runtime constraints
63     * @param OutputInterface $output external output mechanisms
64     *
65     * @return int the status indicator describing the completion
66     */
67    protected function execute(InputInterface $input, OutputInterface $output): int
68    {
69        $output->writeln('<info>Running code standards checks...</info>');
70
71        $this->runCommand('refactor', $input, $output);
72        $this->runCommand('phpdoc', $input, $output);
73        $this->runCommand('code-style', $input, $output);
74        $this->runCommand('reports', $input, $output);
75
76        $output->writeln('<info>All code standards checks completed!</info>');
77
78        return self::SUCCESS;
79    }
80}