Code Duplication    Length = 15-19 lines in 6 locations

src/Handler/AmqpHandlerFactory.php 1 location

@@ 13-31 (lines=19) @@
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
use WShafer\PSR11MonoLog\ServiceTrait;
12
13
class AmqpHandlerFactory implements FactoryInterface, ContainerAwareInterface
14
{
15
    use ServiceTrait;
16
17
    public function __invoke(array $options)
18
    {
19
        $exchange     = $this->getService($options['exchange'] ?? null);
20
        $exchangeName = (string)  ($options['exchangeName'] ?? 'log');
21
        $level        = (int)     ($options['level']     ?? Logger::DEBUG);
22
        $bubble       = (bool) ($options['bubble']    ?? true);
23
24
        return new AmqpHandler(
25
            $exchange,
26
            $exchangeName,
27
            $level,
28
            $bubble
29
        );
30
    }
31
}
32

src/Handler/DynamoDbHandlerFactory.php 1 location

@@ 13-31 (lines=19) @@
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
use WShafer\PSR11MonoLog\ServiceTrait;
12
13
class DynamoDbHandlerFactory implements FactoryInterface, ContainerAwareInterface
14
{
15
    use ServiceTrait;
16
17
    public function __invoke(array $options)
18
    {
19
        $client  = $this->getService($options['client'] ?? null);
20
        $table   = (string)  ($options['table']  ?? null);
21
        $level   = (int)     ($options['level']  ?? Logger::DEBUG);
22
        $bubble  = (bool) ($options['bubble'] ?? true);
23
24
        return new DynamoDbHandler(
25
            $client,
26
            $table,
27
            $level,
28
            $bubble
29
        );
30
    }
31
}
32

src/Handler/MandrillHandlerFactory.php 1 location

@@ 12-30 (lines=19) @@
9
use WShafer\PSR11MonoLog\ContainerAwareInterface;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12
class MandrillHandlerFactory implements FactoryInterface, ContainerAwareInterface
13
{
14
    use SwiftMessageTrait;
15
16
    public function __invoke(array $options)
17
    {
18
        $apiKey  = (string)  ($options['apiKey']  ?? '');
19
        $message = $this->getSwiftMessage($options);
20
        $level   = (int)     ($options['level']   ?? Logger::DEBUG);
21
        $bubble  = (bool) ($options['bubble']  ?? true);
22
23
        return new MandrillHandler(
24
            $apiKey,
25
            $message,
26
            $level,
27
            $bubble
28
        );
29
    }
30
}
31

src/Handler/PHPConsoleHandlerFactory.php 1 location

@@ 13-31 (lines=19) @@
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
use WShafer\PSR11MonoLog\ServiceTrait;
12
13
class PHPConsoleHandlerFactory implements FactoryInterface, ContainerAwareInterface
14
{
15
    use ServiceTrait;
16
17
    public function __invoke(array $options)
18
    {
19
        $consoleOptions = (array)   ($options['options'] ?? []);
20
        $connector      = $this->getService($options['connector'] ?? null);
21
        $level          = (int)     ($options['level']   ?? Logger::DEBUG);
22
        $bubble         = (bool) ($options['bubble']  ?? true);
23
24
        return new PHPConsoleHandler(
25
            $consoleOptions,
26
            $connector,
27
            $level,
28
            $bubble
29
        );
30
    }
31
}
32

src/Handler/SqsHandlerFactory.php 1 location

@@ 13-27 (lines=15) @@
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
use WShafer\PSR11MonoLog\ServiceTrait;
12
13
class SqsHandlerFactory implements FactoryInterface, ContainerAwareInterface
14
{
15
    use ServiceTrait;
16
17
    public function __invoke(array $options)
18
    {
19
        $sqsClient = $this->getService($options['sqsClient'] ?? null);
20
21
        $queueUrl  = (string)  ($options['queueUrl']  ?? Logger::DEBUG);
22
        $level     = (int)     ($options['level']  ?? Logger::DEBUG);
23
        $bubble    = (bool) ($options['bubble'] ?? true);
24
25
        return new SqsHandler($sqsClient, $queueUrl, $level, $bubble);
26
    }
27
}
28

src/Handler/SwiftMailerHandlerFactory.php 1 location

@@ 12-26 (lines=15) @@
9
use WShafer\PSR11MonoLog\ContainerAwareInterface;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12
class SwiftMailerHandlerFactory implements FactoryInterface, ContainerAwareInterface
13
{
14
    use SwiftMessageTrait;
15
16
    public function __invoke(array $options)
17
    {
18
        $mailer  = $this->getService($options['mailer'] ?? null);
19
        $message = $this->getSwiftMessage($options);
20
21
        $level   = (int)     ($options['level']  ?? Logger::DEBUG);
22
        $bubble  = (bool) ($options['bubble'] ?? true);
23
24
        return new SwiftMailerHandler($mailer, $message, $level, $bubble);
25
    }
26
}
27