Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ProxyCommand
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Fast Forward Development Tools for PHP projects.
7 *
8 * This file is part of fast-forward/dev-tools project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/
14 * @see      https://github.com/php-fast-forward/dev-tools
15 * @see      https://github.com/php-fast-forward/dev-tools/issues
16 * @see      https://php-fast-forward.github.io/dev-tools/
17 * @see      https://datatracker.ietf.org/doc/html/rfc2119
18 */
19
20namespace FastForward\DevTools\Composer\Command;
21
22use Composer\Command\BaseCommand;
23use Symfony\Component\Console\Command\Command;
24use Symfony\Component\Console\Input\InputInterface;
25use Symfony\Component\Console\Output\OutputInterface;
26
27/**
28 * Adapts migrated Symfony commands to Composer's BaseCommand contract.
29 */
30 class ProxyCommand extends BaseCommand
31{
32    /**
33     * @param Command $command the Symfony command adapted for Composer plugin execution
34     * @param list<string>|null $aliases the optional alias list exposed to Composer
35     */
36    public function __construct(
37        private  Command $command,
38        ?array $aliases = null,
39    ) {
40        parent::__construct($this->command->getName());
41
42        $this
43            ->setAliases($aliases ?? $this->command->getAliases())
44            ->setDescription($this->command->getDescription())
45            ->setHelp($this->command->getHelp())
46            ->setDefinition(clone $this->command->getDefinition())
47            ->setHidden($this->command->isHidden());
48    }
49
50    /**
51     * Executes the proxied Symfony command through Composer's command contract.
52     *
53     * @param InputInterface $input the Composer command input
54     * @param OutputInterface $output the Composer command output
55     *
56     * @return int the proxied command status code
57     */
58    protected function execute(InputInterface $input, OutputInterface $output): int
59    {
60        return $this->command->run($input, $output);
61    }
62}