NamedCommandExtractor::extract()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace League\Tactician\Plugins\NamedCommand;
4
5
use League\Tactician\Exception\CanNotDetermineCommandNameException;
6
use League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor;
7
8
/**
9
 * Extract the name from a NamedCommand
10
 */
11
class NamedCommandExtractor implements CommandNameExtractor
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 2
    public function extract($command): string
17
    {
18 2
        if ($command instanceof NamedCommand) {
19 1
            return $command->getCommandName();
20
        }
21
22 1
        throw CanNotDetermineCommandNameException::forCommand($command);
23
    }
24
}
25