SlackHandlerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 22
Ratio 84.62 %

Code Coverage

Tests 22
CRAP Score 1

Importance

Changes 0
Metric Value
dl 22
loc 26
ccs 22
cts 22
cp 1
rs 9.504
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Handler;
6
7
use Monolog\Handler\MissingExtensionException;
8
use Monolog\Handler\SlackHandler;
9
use Monolog\Logger;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12 View Code Duplication
class SlackHandlerFactory implements FactoryInterface
13
{
14
    /**
15
     * @param array $options
16
     * @return SlackHandler
17
     * @throws MissingExtensionException
18
     */
19 1
    public function __invoke(array $options)
20
    {
21 1
        $token              = (string)  ($options['token']                  ?? '');
22 1
        $channel            = (string)  ($options['channel']                ?? '');
23 1
        $userName           =            $options['userName']               ?? null;
24 1
        $useAttachment      = (bool) ($options['useAttachment']          ?? true);
25 1
        $iconEmoji          =            $options['iconEmoji']              ?? null;
26 1
        $level              = (int)     ($options['level']                  ?? Logger::DEBUG);
27 1
        $bubble             = (bool) ($options['bubble']                 ?? true);
28 1
        $useShortAttachment = (bool) ($options['useShortAttachment']     ?? false);
29 1
        $includeContext     = (bool) ($options['includeContextAndExtra'] ?? false);
30 1
        $excludeFields      = (array)   ($options['excludeFields']          ?? []);
31
32 1
        return new SlackHandler(
33 1
            $token,
34 1
            $channel,
35 1
            $userName,
36 1
            $useAttachment,
37 1
            $iconEmoji,
38 1
            $level,
39 1
            $bubble,
40 1
            $useShortAttachment,
41 1
            $includeContext,
42 1
            $excludeFields
43
        );
44
    }
45
}
46