Completed
Push — master ( 963443...9b6e1d )
by Thomas Mauro
04:42 queued 03:09
created

Module   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 51
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 4 1
B onBootstrap() 0 27 3
1
<?php
2
3
namespace Facile\SentryModule;
4
5
use Facile\SentryModule\Options\ConfigurationInterface;
6
use Zend\EventManager\EventInterface;
7
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
8
use Zend\ModuleManager\Feature\ConfigProviderInterface;
9
use Zend\Mvc\MvcEvent;
10
11
/**
12
 * Class Module.
13
 */
14
class Module implements ConfigProviderInterface, BootstrapListenerInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function getConfig()
20
    {
21
        return include __DIR__.'/../config/module.config.php';
22
    }
23
24
    /**
25
     * Listen to the bootstrap event.
26
     *
27
     * @param EventInterface $e
28
     *
29
     * @return void
30
     *
31
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
32
     * @throws \Zend\ServiceManager\Exception\InvalidServiceException
33
     * @throws \RuntimeException
34
     * @throws \Interop\Container\Exception\NotFoundException
35
     * @throws \Interop\Container\Exception\ContainerException
36
     */
37 3
    public function onBootstrap(EventInterface $e)
38
    {
39
        /* @var MvcEvent $e */
40 3
        $application = $e->getApplication();
41 3
        $container = $application->getServiceManager();
42
43
        /** @var ConfigurationInterface $configuration */
44 3
        $configuration = $container->get(ConfigurationInterface::class);
45
46 3
        if ($configuration->shouldInjectRavenJavascript()) {
47
            /** @var \Zend\View\HelperPluginManager $viewHelperManager */
48 2
            $viewHelperManager = $container->get('ViewHelperManager');
49
            /** @var \Zend\View\Helper\HeadScript $headScriptHelper */
50 2
            $headScriptHelper = $viewHelperManager->get('HeadScript');
51 2
            $jsScript = $configuration->getRavenJavascriptUri();
52 2
            if (! empty($jsScript)) {
53 1
                $headScriptHelper->appendFile($jsScript);
54
            }
55 2
            $headScriptHelper->appendScript(
56 2
                sprintf(
57 2
                    'Raven.config(\'%s\', %s).install();',
58 2
                    $configuration->getRavenJavascriptDsn(),
59 2
                    json_encode($configuration->getRavenJavascriptOptions())
60
                )
61
            );
62
        }
63 3
    }
64
}
65