Module::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
c 6
b 0
f 0
dl 0
loc 4
rs 10
nc 1
cc 1
eloc 2
nop 0
1
<?php
2
3
namespace AtAdmin;
4
5
use AtAdmin\Controller\DashboardController;
6
use AtAdmin\Controller\Plugin\BackTo;
7
use Zend\Mvc\MvcEvent;
8
use Zend\Mvc\Router\RouteMatch;
9
use Zend\ServiceManager\Factory\InvokableFactory;
10
11
class Module
12
{
13
    public function getConfig()
14
    {
15
        return include __DIR__ . '/../config/module.config.php';
16
    }
17
18
    /**
19
     * @return array
20
     */
21
    public function getControllerConfig()
22
    {
23
        return [
24
            'factories' => [
25
                DashboardController::class => InvokableFactory::class,
26
            ],
27
        ];
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function getControllerPluginConfig()
34
    {
35
        return [
36
            'invokables' => [
37
                'backTo' => BackTo::class
38
            ],
39
        ];
40
    }
41
42
43
    /**
44
     * @param MvcEvent $e
45
     */
46
    public function onBootstrap(MvcEvent $e)
47
    {
48
        $app = $e->getApplication();
49
        $app->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) use ($app) {
50
            $config = $app->getServiceManager()->get('config');
51
52
            $routeMatch = $e->getRouteMatch();
53
            $controller = $e->getTarget();
54
            if (!$routeMatch instanceof RouteMatch
0 ignored issues
show
Bug introduced by
The class Zend\Mvc\Router\RouteMatch does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
55
                || 0 !== strpos($routeMatch->getMatchedRouteName(), 'at-admin')
56
                || $controller->getEvent()->getResult()->terminate()
57
            ) {
58
                return;
59
            }
60
61
            if (isset($config['at-admin']['layout'])) {
62
                $controller->layout($config['at-admin']['layout']);
63
            }
64
        });
65
    }
66
}