CommandNameMatcher::matches()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Crummy\Phlack\Common\Matcher;
4
5
use Crummy\Phlack\WebHook\CommandInterface;
6
7
class CommandNameMatcher implements MatcherInterface
8
{
9
    protected $commandName;
10
11
    /**
12
     * @param string|null $commandName
13
     */
14 16
    public function __construct($commandName = null)
15
    {
16 16
        $this->commandName = $commandName;
17 16
    }
18
19
    /**
20
     * @param CommandInterface $command
21
     *
22
     * @return bool
23
     */
24 5
    public function matches(CommandInterface $command)
25
    {
26 5
        return $this->getCommandName() === $command->get('command');
27
    }
28
29
    /**
30
     * @param $command
31
     *
32
     * @return $this
33
     */
34 6
    public function setCommandName($command)
35
    {
36 6
        $this->commandName = $command;
37
38 6
        return $this;
39
    }
40
41
    /**
42
     * @return null|string
43
     */
44 6
    public function getCommandName()
45
    {
46 6
        return $this->commandName;
47
    }
48
}
49