Completed
Push — master ( 622c37...dca855 )
by Christian
04:12
created

SelfTestSuhosin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doTest() 0 15 2
A isSuhosinLoaded() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\SelfTest\Php;
22
23
use Tenside\Core\SelfTest\AbstractSelfTest;
24
25
/**
26
 * This class tests the current environment for correctly configured suhosin extension is suitable for running tenside.
27
 */
28
class SelfTestSuhosin extends AbstractSelfTest
29
{
30
    /**
31
     * Check that Suhosin is correctly configured.
32
     *
33
     * @return void
34
     */
35
    public function doTest()
36
    {
37
        $this->setMessage('Check if Suhosin is either not loaded or correctly configured.');
38
39
        if (!$this->isSuhosinLoaded()) {
40
            $this->markSuccess();
41
            return;
42
        }
43
44
        $this->markFailed(
45
            'The php setting allow_url_fopen must be enabled to allow downloading of data. ' .
46
            'Note that this does NOT imply any security risk as this is NOT the setting allow_url_include ' .
47
            '(which should be disabled).'
48
        );
49
    }
50
51
    /**
52
     * Check if Suhosin is loaded.
53
     *
54
     * @return bool
55
     */
56
    private function isSuhosinLoaded()
57
    {
58
        return extension_loaded('suhosin');
59
    }
60
}
61