Module   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onBootstrap() 0 19 2
A getConfig() 0 22 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\ZFLinkHeadersModule;
6
7
use Facile\ZFLinkHeadersModule\Listener\LinkHandler;
8
use Facile\ZFLinkHeadersModule\Listener\ScriptHandler;
9
use Facile\ZFLinkHeadersModule\Listener\StylesheetHandler;
10
use Zend\EventManager\EventInterface;
11
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
12
use Zend\ModuleManager\Feature\ConfigProviderInterface;
13
use Zend\Mvc\MvcEvent;
14
15
final class Module implements BootstrapListenerInterface, ConfigProviderInterface
16
{
17
    /**
18
     * @param EventInterface $e
19
     * @return array|void
20
     * @throws \Psr\Container\ContainerExceptionInterface
21
     * @throws \Psr\Container\NotFoundExceptionInterface
22
     */
23 2
    public function onBootstrap(EventInterface $e)
24
    {
25 2
        if (! $e instanceof MvcEvent) {
26 1
            return;
27
        }
28
29 1
        $app = $e->getApplication();
30 1
        $container = $app->getServiceManager();
31 1
        $eventManager = $app->getEventManager();
32
33 1
        $linkHandler = $container->get(LinkHandler::class);
34 1
        $eventManager->attach(MvcEvent::EVENT_FINISH, $linkHandler);
35
36 1
        $stylesheetHandler = $container->get(StylesheetHandler::class);
37 1
        $eventManager->attach(MvcEvent::EVENT_FINISH, $stylesheetHandler);
38
39 1
        $scriptHandler = $container->get(ScriptHandler::class);
40 1
        $eventManager->attach(MvcEvent::EVENT_FINISH, $scriptHandler);
41 1
    }
42
43
    /**
44
     * Returns configuration to merge with application configuration
45
     *
46
     * @return array|\Traversable
47
     */
48 1
    public function getConfig()
49
    {
50
        return [
51 1
            'facile' => [
52
                'zf_link_headers_module' => [
53
                    'stylesheet_enabled' => false,
54
                    'stylesheet_mode' => 'preload',
55
                    'script_enabled' => false,
56
                    'script_mode' => 'preload',
57
                    'http2_push_enabled' => true,
58
                ],
59
            ],
60
            'service_manager' => [
61
                'factories' => [
62
                    OptionsInterface::class => Service\OptionsConfigFactory::class,
63
                    Listener\LinkHandler::class => Listener\LinkHandlerFactory::class,
64
                    Listener\StylesheetHandler::class => Listener\StylesheetHandlerFactory::class,
65
                    Listener\ScriptHandler::class => Listener\ScriptHandlerFactory::class,
66
                ],
67
            ],
68
        ];
69
    }
70
}
71