ItemRocketChat::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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
 * php version 7.1.0
11
 *
12
 * @category  Web-security
13
 * @package   Shieldon
14
 * @author    Terry Lin <[email protected]>
15
 * @copyright 2019 terrylinooo
16
 * @license   https://github.com/terrylinooo/shieldon/blob/2.x/LICENSE MIT
17
 * @link      https://github.com/terrylinooo/shieldon
18
 * @see       https://shieldon.io
19
 */
20
21
declare(strict_types=1);
22
23
namespace Shieldon\Firewall\Firewall\Messenger;
24
25
use Shieldon\Messenger\Messenger\MessengerInterface;
26
use Shieldon\Messenger\RocketChat;
27
28
/**
29
 * The get for RocketChat.
30
 */
31
class ItemRocketChat
32
{
33
    /**
34
     * Initialize and get the instance.
35
     *
36
     * @param array $setting The configuration of that messanger.
37
     *
38
     * @return MessengerInterface
39
     */
40 1
    public static function get(array $setting): MessengerInterface
41
    {
42 1
        $serverUrl   = $setting['config']['server_url'] ?? '';
43 1
        $userId      = $setting['config']['user_id'] ?? '';
44 1
        $accessToken = $setting['config']['access_token'] ?? '';
45 1
        $channel     = $setting['config']['channel'] ?? '';
46
47 1
        return new RocketChat($accessToken, $userId, $serverUrl, $channel);
48
    }
49
}
50