Completed
Push — master ( 670b18...db08df )
by Matthias
10s
created

Module::getServiceConfig()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 60
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 8
Bugs 2 Features 3
Metric Value
c 8
b 2
f 3
dl 0
loc 60
ccs 1
cts 1
cp 1
rs 9.5555
cc 2
eloc 33
nc 1
nop 0
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace MaglMarkdown;
4
5
use MaglMarkdown\Cache\CacheListener;
6
use Zend\ModuleManager\Feature;
7
use Zend\Mvc\MvcEvent;
8
9
/**
10
 * MaglMarkdown is a ZF2 module to provide a View Helper that is able to
11
 * transform Markdown to html
12
 *
13
 * @author Matthias Glaub <[email protected]>
14
 */
15
class Module implements
16
    Feature\AutoloaderProviderInterface,
17
    Feature\ConfigProviderInterface,
18
    Feature\ViewHelperProviderInterface
19
{
20
21 1
    public function onBootstrap(MvcEvent $e)
22
    {
23
        // attach the cache listener, if caching is enabled
24 1
        $sm = $e->getApplication()->getServiceManager();
25 1
        $config = $sm->get('config');
26 1
        if ($config['magl_markdown']['cache_enabled']) {
27 1
            $em = $e->getApplication()->getEventManager();
28
            /** @var CacheListener $listener */
29 1
            $listener = $sm->get('MaglMarkdown\CacheListener');
30 1
            $listener->attach($em);
31 1
        }
32 1
    }
33
34
    /**
35
     * @return array
36
     */
37 4
    public function getConfig()
38
    {
39 4
        return include __DIR__ . '/../../config/module.config.php';
40
    }
41
42
    /**
43
     * @return array
44
     */
45 1
    public function getAutoloaderConfig()
46
    {
47
        return array(
48
            'Zend\Loader\StandardAutoloader' => array(
49
                'namespaces' => array(
50 1
                    __NAMESPACE__ => __DIR__,
51 1
                ),
52 1
            ),
53 1
        );
54
    }
55
56
    /**
57
     * @return array
58
     */
59 1
    public function getViewHelperConfig()
60
    {
61
        return array(
62
            'aliases' => array(
63 1
                'markdown' => 'MaglMarkdown\View\Helper\Markdown',
64 1
            ),
65
            'factories' => array(
66 1
                'MaglMarkdown\View\Helper\Markdown' => 'MaglMarkdown\View\Helper\MarkdownFactory',
67 1
            ),
68 1
        );
69
    }
70
}
71