Completed
Push — master ( 8ed961...3d9e83 )
by Dan
05:14
created

MethodMatcher::matches()   C

Complexity

Conditions 12
Paths 13

Size

Total Lines 37
Code Lines 22

Duplication

Lines 8
Ratio 21.62 %

Importance

Changes 0
Metric Value
dl 8
loc 37
rs 5.1612
c 0
b 0
f 0
cc 12
eloc 22
nc 13
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Nopolabs\Yabot\Plugin;
4
5
6
use Nopolabs\Yabot\Helpers\LogTrait;
7
use Nopolabs\Yabot\Helpers\MatcherTrait;
8
use Nopolabs\Yabot\Message\Message;
9
use Psr\Log\LoggerInterface;
10
11
class MethodMatcher
12
{
13
    use LogTrait;
14
    use MatcherTrait;
15
16
    private $method;
17
18
    public function __construct(
19
        string $name,
20
        $isBot,
21
        array $channels,
22
        array $users,
23
        array $patterns,
24
        string $method,
25
        LoggerInterface $logger)
26
    {
27
        $this->setName($name);
28
        $this->setIsBot($isBot);
29
        $this->setChannels($channels);
30
        $this->setUsers($users);
31
        $this->setPatterns($patterns);
32
        $this->setLog($logger);
33
34
        $this->method = $method;
35
    }
36
37
    public function getName(): string
38
    {
39
        return $this->name;
40
    }
41
42
    public function getMethod(): string
43
    {
44
        return $this->method;
45
    }
46
}