CommandRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PjbServer\Tools\Console;
6
7
use Symfony\Component\Console\Command\Command as ConsoleCommand;
8
9
class CommandRepository
10
{
11
    /**
12 7
     * @var array<string, ConsoleCommand>
13
     */
14 7
    protected $commands;
15 7
16 7
    public function __construct()
17 7
    {
18 7
        $this->commands = [
19 7
            'pjbserver:start' => new Command\PjbServerStartCommand(),
20 7
            'pjbserver:restart' => new Command\PjbServerRestartCommand(),
21 7
            'pjbserver:stop' => new Command\PjbServerStopCommand(),
22
            'pjbserver:status' => new Command\PjbServerStatusCommand(),
23
            'pjbserver:reveal' => new Command\PjbServerRevealCommand()
24
        ];
25
    }
26
27
    public function getRegisteredCommand(string $name): ConsoleCommand
28 7
    {
29
        return $this->commands[$name];
30 7
    }
31
32
    /**
33
     * Return all registered commands.
34
     *
35
     * @return array<string, ConsoleCommand>
36
     */
37
    public function getRegisteredCommands(): array
38
    {
39
        return $this->commands;
40
    }
41
}
42