CommandNameMatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 4 1
A getCommandName() 0 4 1
A setCommandName() 0 6 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