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

SqsHandlerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Handler;
5
6
use Monolog\Handler\SqsHandler;
7
use Monolog\Logger;
8
use WShafer\PSR11MonoLog\ContainerAwareInterface;
9
use WShafer\PSR11MonoLog\FactoryInterface;
10
use WShafer\PSR11MonoLog\ServiceTrait;
11
12 View Code Duplication
class SqsHandlerFactory implements FactoryInterface, ContainerAwareInterface
13
{
14
    use ServiceTrait;
15
16
    public function __invoke(array $options)
17
    {
18
        $sqsClient = $this->getService($options['sqsClient'] ?? null);
19
20
        $queueUrl  = (string)  ($options['queueUrl']  ?? Logger::DEBUG);
21
        $level     = (int)     ($options['level']  ?? Logger::DEBUG);
22
        $bubble    = (boolean) ($options['bubble'] ?? true);
23
24
        return new SqsHandler($sqsClient, $queueUrl, $level, $bubble);
25
    }
26
}
27