Help   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
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 27
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
     * @throws \Exception
16
     *
17
     * @return string
18
     */
19 2
    public function index(): string
20
    {
21 2
        $allCommands = $this->getSlackbot()->getCommands();
22
23 2
        $response = '';
24 2
        if (!empty($allCommands)) {
25 2
            $formattingUtility = (new FormattingUtility());
26
27 2
            foreach ($allCommands as $commandName => $commandObject) {
28 2
                if (!$commandObject instanceof Command) {
29 1
                    continue;
30
                }
31
32 1
                $response .= "/{$commandName} - ".$commandObject->getDescription().$formattingUtility->newLine();
33
            }
34
        }
35
36 2
        return $response;
37
    }
38
}
39