Completed
Push — master ( 89c9f0...9aceec )
by Thomas Mauro
06:33
created

ClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 2
1
<?php
2
3
namespace Facile\SentryModule\Service;
4
5
use Facile\SentryModule\Options\ClientOptions;
6
use Interop\Container\ContainerInterface;
7
8
class ClientFactory extends AbstractFactory
9
{
10
    /**
11
     * @param ContainerInterface $container
12
     * @return Client
13
     * @throws \Interop\Container\Exception\NotFoundException
14
     * @throws \Interop\Container\Exception\ContainerException
15
     */
16
    public function __invoke(ContainerInterface $container)
17
    {
18
        /** @var array $optionsArray */
19
        $optionsArray = $container->get('config')['facile']['sentry']['client'][$this->name];
20
        
21
        $options = new ClientOptions($optionsArray);
22
23
        $ravenClient = new \Raven_Client($options->getDsn(), $options->getOptions());
24
25
        $client = new Client($ravenClient, $options);
26
27
        $errorHandlerListener = $container->get($options->getErrorHandlerListener());
28
        if ($errorHandlerListener instanceof ClientAwareInterface) {
29
            $errorHandlerListener->setClient($client);
30
        }
31
        $client->setErrorHandlerListener($errorHandlerListener);
32
        
33
        return $client;
34
    }
35
}
36