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

Help::index()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 2
nop 0
crap 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