Completed
Push — master ( bcf115...e66e23 )
by Matthias
11:44
created

Module::onBootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * @author Matthias Glaub <[email protected]>
5
 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
6
 */
7
8
namespace MaglLegacyApplication;
9
10
use MaglLegacyApplication\Application\MaglLegacy;
11
use Zend\Mvc\MvcEvent;
12
use Zend\Mvc\Router\RouteMatch;
13
use Zend\ServiceManager\ServiceManager;
14
15
class Module
16
{
17 4
    public function onBootstrap(MvcEvent $event)
18
    {
19 4
        MaglLegacy::getInstance()->setApplication($event->getApplication());
20 4
    }
21
22 5
    public function getConfig()
23
    {
24 5
        return include realpath(__DIR__ . '/../../config/module.config.php');
25
    }
26
27 5
    public function getControllerConfig()
28
    {
29
        return array(
30
            'factories' => array(
31
                'MaglLegacyApplication\Controller\Legacy' => function ($sl) {
32 5
                    $options = $sl->getServiceLocator()->get('MaglLegacyApplicationOptions');
33
34 5
                    $legacyApp = Application\MaglLegacy::getInstance();
35
36 5
                    return new \MaglLegacyApplication\Controller\LegacyController($options, $legacyApp);
37
                }
38 5
            )
39 5
        );
40
    }
41
42 5
    public function getServiceConfig()
43
    {
44
        return array(
45
            'factories' => array(
46
                'MaglLegacyApplicationOptions' => function ($sl) {
47 5
                    $config = $sl->get('Config');
48 5
                    $options = $config['magl_legacy_application'];
49
50 5
                    return new Options\LegacyControllerOptions($options);
51 5
                },
52 1
                'MaglControllerService' => function (ServiceManager $sl) {
53
54 1
                    $eventManager = $sl->get('Application')->getEventManager();
55
56 1
                    $event = new \Zend\Mvc\MvcEvent();
57 1
                    $event->setApplication($sl->get('Application'));
0 ignored issues
show
Documentation introduced by
$sl->get('Application') is of type object|array, but the function expects a object<Zend\Mvc\ApplicationInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
58 1
                    $event->setTarget($sl->get('Application'));
0 ignored issues
show
Bug introduced by
It seems like $sl->get('Application') targeting Zend\ServiceManager\ServiceManager::get() can also be of type array; however, Zend\EventManager\Event::setTarget() does only seem to accept null|string|object, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
59 1
                    $event->setRequest($sl->get('Request'));
0 ignored issues
show
Documentation introduced by
$sl->get('Request') is of type object|array, but the function expects a object<Zend\Stdlib\RequestInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60 1
                    $event->setRouter($sl->get('Router'));
0 ignored issues
show
Documentation introduced by
$sl->get('Router') is of type object|array, but the function expects a object<Zend\Mvc\Router\RouteStackInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
61 1
                    $event->setRouteMatch(new RouteMatch(array()));
62
63 1
                    return new Service\ControllerService($eventManager, $event);
64
                }
65 5
            )
66 5
        );
67
    }
68
69 5
    public function getAutoloaderConfig()
70
    {
71
        return array(
72
            'Zend\Loader\StandardAutoloader' => array(
73
                'namespaces' => array(
74 5
                    __NAMESPACE__ => __DIR__,
75 5
                ),
76 5
            ),
77 5
        );
78
    }
79
}
80