Passed
Push — master ( ff83e3...5f4a5c )
by Ehsan
03:54
created

Help   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 19 4
1
<?php
2
3
namespace Botonomous\plugin\help;
4
5
use Botonomous\Command;
6
use Botonomous\plugin\AbstractPlugin;
7
use Botonomous\utility\FormattingUtility;
8
9
/**
10
 * Class Help.
11
 */
12
class Help extends AbstractPlugin
13
{
14
    /**
15
     * @return string
16
     */
17 2
    public function index()
18
    {
19 2
        $allCommands = $this->getSlackbot()->getCommands();
20
21 2
        $response = '';
22 2
        if (!empty($allCommands)) {
23 2
            $formattingUtility = (new FormattingUtility());
24
25 2
            foreach ($allCommands as $commandName => $commandObject) {
26 2
                if (!$commandObject instanceof Command) {
27 1
                    continue;
28
                }
29
30 1
                $response .= "/{$commandName} - ".$commandObject->getDescription().$formattingUtility->newLine();
31
            }
32
        }
33
34 2
        return $response;
35
    }
36
}
37