1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\PackBundle
;
14 use Symfony\Component\Console\Command\Command
as BaseCommand
;
15 use Symfony\Component\DependencyInjection\Container
;
17 use Rapsys\PackBundle\RapsysPackBundle
;
22 class Command
extends BaseCommand
{
26 public function __construct(protected ?string $name = null) {
28 $this->name
= $this->name
?? static::getName();
30 //Call parent constructor
31 parent
::__construct($this->name
);
34 if (!empty($this->description
)) {
36 $this->setDescription($this->description
);
40 if (!empty($this->help
)) {
42 $this->setHelp($this->help
);
47 * Return the command name
51 public function getName(): string {
53 if ($npos = strrpos(static::class, '\\')) {
61 //With trailing command
62 if (substr(static::class, -strlen('Command'), strlen('Command')) === 'Command') {
64 $bpos = strlen(static::class) - $npos - strlen('Command');
68 $bpos = strlen(static::class) - $npos;
71 //Return command alias
72 return RapsysPackBundle
::getAlias().':'.strtolower(substr(static::class, $npos, $bpos));