PhpSettings   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBootstrap() 0 10 4
1
<?php
2
/**
3
 * Polder Knowledge / PhpSettingsModule (https://polderknowledge.com)
4
 *
5
 * @link https://github.com/polderknowledge/phpsettings-module for the canonical source repository
6
 * @copyright Copyright (c) 2002-2016 Polder Knowledge (https://www.polderknowledge.com)
7
 * @license https://github.com/polderknowledge/phpsettings-module/blob/master/LICENSE.md MIT
8
 */
9
10
namespace PolderKnowledge\PhpSettingsModule\Listener;
11
12
use Zend\Mvc\MvcEvent;
13
14
/**
15
 * The PhpSettings class is a listener that listens to the bootstrap event. At that moment the config array is read
16
 * and all configured PHP settings are set.
17
 */
18
class PhpSettings
19
{
20
    /**
21
     * The callback method that is called on bootstrap.
22
     *
23
     * @param MvcEvent $e The event parameters that were passed to the bootstrap event.
24
     */
25 3
    public function onBootstrap(MvcEvent $e)
26 1
    {
27 3
        $config = $e->getApplication()->getConfig();
28
29 3
        if (isset($config['phpSettings']) && is_array($config['phpSettings'])) {
30 3
            foreach ($config['phpSettings'] as $key => $value) {
31 3
                ini_set($key, $value);
32 3
            }
33 3
        }
34 3
    }
35
}
36