Lookup   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A lookupUser() 0 4 1
A lookupChannel() 0 4 1
1
<?php
2
3
namespace Nopolabs\Yabot\Plugins\Examples;
4
5
use Nopolabs\Yabot\Message\Message;
6
use Nopolabs\Yabot\Plugin\PluginInterface;
7
use Nopolabs\Yabot\Plugin\PluginTrait;
8
use Psr\Log\LoggerInterface;
9
10
class Lookup implements PluginInterface
11
{
12
    use PluginTrait;
13
14
    public function __construct(
15
        LoggerInterface $logger,
16
        array $config = [])
17
    {
18
        $this->setLog($logger);
19
20
        $this->setConfig(array_merge(
21
            [
22
                'prefix' => 'lookup',
23
                'matchers' => [
24
                    'lookupUser' => "/^@(?'user'\\w+)\\b/",
25
                    'lookupChannel' => "/^#(?'channel'\\w+)\\b/",
26
                ],
27
            ],
28
            $config
29
        ));
30
    }
31
32
    public function lookupUser(Message $msg, array $matches)
33
    {
34
        $msg->reply('user: '.$matches['user']);
35
    }
36
37
    public function lookupChannel(Message $msg, array $matches)
38
    {
39
        $msg->reply('channel: '.$matches['channel']);
40
    }
41
}