PhpSettings::onBootstrap()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 9
cts 9
cp 1
rs 9.2
cc 4
eloc 5
nc 3
nop 1
crap 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