Completed
Push — master ( 8c4272...ef6d68 )
by Thomas Mauro
11s
created

Module   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 6
dl 0
loc 48
ccs 14
cts 16
cp 0.875
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 4 1
B onBootstrap() 0 24 2
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 2
    public function onBootstrap(EventInterface $e)
38
    {
39
        /* @var MvcEvent $e */
40 2
        $application = $e->getApplication();
41 2
        $container = $application->getServiceManager();
42
43
        /** @var ConfigurationInterface $configuration */
44 2
        $configuration = $container->get(ConfigurationInterface::class);
45
46 2
        if ($configuration->shouldInjectRavenJavascript()) {
47
            /** @var \Zend\View\HelperPluginManager $viewHelperManager */
48 1
            $viewHelperManager = $container->get('ViewHelperManager');
49
            /** @var \Zend\View\Helper\HeadScript $headScriptHelper */
50 1
            $headScriptHelper = $viewHelperManager->get('HeadScript');
51 1
            $headScriptHelper->appendFile($configuration->getRavenJavascriptUri());
52 1
            $headScriptHelper->appendScript(
53 1
                sprintf(
54 1
                    'Raven.config(\'%s\', %s).install();',
55 1
                    $configuration->getRavenJavascriptDsn(),
56 1
                    json_encode($configuration->getRavenJavascriptOptions())
57
                )
58
            );
59
        }
60 2
    }
61
}
62