AbstractAdapter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 58.33%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
c 3
b 1
f 0
lcom 1
cbo 2
dl 0
loc 52
ccs 7
cts 12
cp 0.5833
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getConverter() 0 4 1
A __construct() 0 5 2
A setMainframe() 0 6 1
A attach() 0 6 1
1
<?php
2
3
namespace Crummy\Phlack\Bot\Mainframe\Adapter;
4
5
use Crummy\Phlack\Bot\BotInterface;
6
use Crummy\Phlack\Bot\Mainframe\Mainframe;
7
use Crummy\Phlack\Common\Matcher\MatcherInterface;
8
use Crummy\Phlack\WebHook\Converter\ConverterInterface;
9
use Crummy\Phlack\WebHook\Converter\StringConverter;
10
11
class AbstractAdapter implements AdapterInterface
12
{
13
    /** @var Mainframe */
14
    protected $mainframe;
15
16
    /** @var StringConverter|ConverterInterface */
17
    protected $converter;
18
19
    /**
20
     * @param Mainframe          $mainframe
21
     * @param ConverterInterface $converter
22
     */
23 6
    public function __construct(Mainframe $mainframe, ConverterInterface $converter = null)
24
    {
25 6
        $this->setMainframe($mainframe);
26 6
        $this->converter = $converter ?: new StringConverter();
27 6
    }
28
29
    /**
30
     * @param Mainframe $mainframe
31
     *
32
     * @return self
33
     */
34 6
    public function setMainframe(Mainframe $mainframe)
35
    {
36 6
        $this->mainframe = $mainframe;
37
38 6
        return $this;
39
    }
40
41
    /**
42
     * @return \Crummy\Phlack\WebHook\Converter\ConverterInterface
43
     */
44
    public function getConverter()
45
    {
46
        return $this->converter;
47
    }
48
49
    /**
50
     * @param BotInterface              $bot
51
     * @param MatcherInterface|callable $matcher
52
     * @param int                       $priority
53
     *
54
     * @return self
55
     */
56
    public function attach(BotInterface $bot, $matcher = null, $priority = 0)
57
    {
58
        $this->mainframe->attach($bot, $matcher, $priority);
59
60
        return $this;
61
    }
62
}
63