SentryLoggerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
namespace Dasao\SentryLogger\Log;
4
5
use Interop\Container\ContainerInterface;
6
use Psr\Container\ContainerExceptionInterface;
7
use Psr\Container\NotFoundExceptionInterface;
8
use Raven_Client;
9
use Zend\ServiceManager\Factory\FactoryInterface;
10
11
/**
12
 * Class SentryLoggerFactory
13
 *
14
 * PHP Version 7
15
 *
16
 * @category  PHP
17
 * @package   Dasao\SentryLogger\Log
18
 * @author    Dasao <[email protected]>
19
 * @copyright 2014-2017 Dasao
20
 * @license   Proprietary http://www.das-ao.com
21
 */
22
class SentryLoggerFactory implements FactoryInterface
23
{
24
    /**
25
     * Invoke the factory.
26
     *
27
     *
28
     * @param ContainerInterface $container     The DI container.
29
     * @param  string            $requestedName The requested class name.
30
     * @param  null|array        $options       Optional options.
31
     *
32
     * @return SentryLoggerInterface
33
     * @throws ContainerExceptionInterface
34
     * @throws NotFoundExceptionInterface
35
     */
36
    public function __invoke(
37
        ContainerInterface $container,
38
        $requestedName,
39
        array $options = null
40
    ) : SentryLoggerInterface {
41
        /** @var SentryLoggerConfigInterface $sentryLoggerConfig */
42
        $sentryLoggerConfig = $container->get(SentryLoggerConfig::class);
43
44
        $sentryClient = new Raven_Client($sentryLoggerConfig->getDsn(), $sentryLoggerConfig->getOptions());
45
46
        return new SentryLogger($sentryClient);
47
    }
48
49
}
50