Completed
Push — master ( 537349...e26b4a )
by Westin
11:04
created

SendGridHandlerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 20 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Handler;
5
6
use Monolog\Handler\SendGridHandler;
7
use Monolog\Logger;
8
use WShafer\PSR11MonoLog\FactoryInterface;
9
10
class SendGridHandlerFactory implements FactoryInterface
11
{
12
    public function __invoke(array $options)
13
    {
14
        $apiUser    = (string)  ($options['apiUser'] ?? '');
15
        $apiKey     = (string)  ($options['apiKey']  ?? '');
16
        $from       = (string)  ($options['from']    ?? '');
17
        $to         =           ($options['to']      ?? '');
18
        $subject    = (string)  ($options['subject'] ?? '');
19
        $level      = (int)     ($options['level']   ?? Logger::DEBUG);
20
        $bubble     = (boolean) ($options['bubble']  ?? true);
21
22
        return new SendGridHandler(
23
            $apiUser,
24
            $apiKey,
25
            $from,
26
            $to,
27
            $subject,
28
            $level,
29
            $bubble
30
        );
31
    }
32
}
33