Passed
Push — 2.x ( a2237c...c5863b )
by Terry
02:56
created

ItemRocketChat   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 1
1
<?php
2
/*
3
 * This file is part of the Shieldon package.
4
 *
5
 * (c) Terry L. <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Shieldon\Firewall\Firewall\Messenger;
14
15
use Shieldon\Messenger\Messenger\MessengerInterface;
16
use Shieldon\Messenger\RocketChat;
17
18
/**
19
 * The get for RocketChat.
20
 */
21
class ItemRocketChat
22
{
23
    /**
24
     * Initialize and get the instance.
25
     *
26
     * @param array $setting The configuration of that messanger.
27
     *
28
     * @return MessengerInterface
29
     */
30
    public static function get(array $setting): MessengerInterface
31
    {
32
        $serverUrl   = $setting['config']['server_url']   ?? '';
33
        $userId      = $setting['config']['user_id']      ?? '';
34
        $accessToken = $setting['config']['access_token'] ?? '';
35
        $channel     = $setting['config']['channel']      ?? '';
36
37
        return new RocketChat($accessToken, $userId, $serverUrl, $channel);
38
    }
39
}