BotCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getConverter() 0 4 1
A execute() 0 4 1
A __construct() 0 6 1
A setMainframe() 0 6 1
A attach() 0 6 1
1
<?php
2
3
namespace Crummy\Phlack\Bridge\Symfony\Console;
4
5
use Crummy\Phlack\Bot\BotInterface;
6
use Crummy\Phlack\Bot\Mainframe\Adapter\AdapterInterface;
7
use Crummy\Phlack\Bot\Mainframe\Mainframe;
8
use Crummy\Phlack\Common\Matcher\MatcherInterface;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class BotCommand extends Command implements AdapterInterface
14
{
15
    private $adapter;
16
17
    /**
18
     * @param ConsoleAdapter $adapter
19
     * @param string         $name
20
     */
21 6
    public function __construct(ConsoleAdapter $adapter, $name = 'bot_command')
22
    {
23 6
        parent::__construct($name);
24
25 6
        $this->adapter = $adapter;
26 6
    }
27
28
    /**
29
     * @param Mainframe $mainframe
30
     *
31
     * @return self
32
     */
33 1
    public function setMainframe(Mainframe $mainframe)
34
    {
35 1
        $this->adapter->setMainframe($mainframe);
36
37 1
        return $this;
38
    }
39
40
    /**
41
     * @return \Crummy\Phlack\WebHook\Converter\ConverterInterface
42
     */
43 1
    public function getConverter()
44
    {
45 1
        return $this->adapter->getConverter();
46
    }
47
48
    /**
49
     * @param BotInterface              $bot
50
     * @param MatcherInterface|callable $matcher
51
     * @param int                       $priority
52
     *
53
     * @return self
54
     */
55 1
    public function attach(BotInterface $bot, $matcher = null, $priority = 0)
56
    {
57 1
        $this->adapter->attach($bot, $matcher, $priority);
58
59 1
        return $this;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    protected function execute(InputInterface $input, OutputInterface $output)
66
    {
67
        $this->adapter->execute($input, $output);
68
    }
69
}
70