HelpPlugin::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
namespace Nopolabs\Yabot\Plugin;
3
4
use Nopolabs\Yabot\Message\Message;
5
use Nopolabs\Yabot\Yabot;
6
use Psr\Log\LoggerInterface;
7
8
class HelpPlugin implements PluginInterface
9
{
10
    use PluginTrait;
11
12
    private $yabot;
13
14
    public function __construct(Yabot $yabot, LoggerInterface $logger = null)
15
    {
16
        $this->setLog($logger);
17
        $this->yabot = $yabot;
18
19
        $this->setConfig([
20
            'help' => '<prefix> help',
21
            'prefix' => PluginManager::AUTHED_USER_PREFIX,
22
            'matchers' => ['yabotHelp' => "/^help\\b/"],
23
        ]);
24
    }
25
26
    public function yabotHelp(Message $msg)
27
    {
28
        $msg->reply($this->yabot->getHelp());
29
        $msg->setHandled(true);
30
    }
31
}
32