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

ItemRocketChat::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
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
}