CommandRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 31
ccs 11
cts 12
cp 0.9167
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getRegisteredCommands() 0 3 1
A getRegisteredCommand() 0 3 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