Passed
Push — master ( cd9ea8...ce0baf )
by Tim
01:23
created

Database::invokeTest()   A

Complexity

Conditions 6
Paths 10

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nc 10
nop 0
dl 0
loc 26
rs 9.1111
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor\TestSuite\Configuration;
4
5
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration;
6
use \SimpleSAML\Module\monitor\TestCase as TestCase;
7
use \SimpleSAML\Module\monitor\TestData as TestData;
8
use \SimpleSAML\Module\monitor\TestResult as TestResult;
9
use \SimpleSAML\Module\monitor\State as State;
10
use \SimpleSAML\Utils as Utils;
11
12
final class Database extends \SimpleSAML\Module\monitor\TestSuiteFactory
13
{
14
    /**
15
     * var string|null
16
     */
17
    private $store = null;
18
19
    /**
20
     * var array
21
     */
22
    private $metadataSources = [];
23
24
    /**
25
     * var array
26
     */
27
    private $dependentModules = ['consent'];
28
29
    /**
30
     * @param TestConfiguration $configuration
31
     */
32
    public function __construct($configuration)
33
    {
34
        $globalConfig = $configuration->getGlobalConfig();
35
        $this->store = $globalConfig->getString('store.type', 'phpsession');
36
        $this->metadataSources = $globalConfig->getArray('metadata.sources', array());
37
38
        $this->setCategory('Configuration');
39
        parent::__construct($configuration);
40
    }
41
42
    /**
43
     * @return void
44
     */
45
    public function invokeTest()
46
    {
47
        if ($this->store === 'sql') {
48
            // We use a database for session-storage
49
        } else if (in_array(array('type' => 'pdo'), $this->metadataSources, true)) {
50
            // We use a database for metadata-storage
51
        } else {
52
            $dependent = false;
53
            foreach ($module as $this->dependentModules) {
54
                if (\SimpleSAML\Module::isModuleEnabled($module)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $module seems to be never defined.
Loading history...
55
                    $dependent = true;
56
                    break 1;
57
                }
58
            }
59
            if ($dependent === false) {
60
                $testResult = new TestResult('Configuration', '');
61
                $testResult->setState(State::SKIPPED);
62
                $this->setTestResult($testResult);
63
                return;
64
            }
65
        }
66
67
        // We are using the database-configuration in some way, so start testing it!
68
        $testResult = new TestResult('Configuration', '');
69
        $testResult->setState(State::OK);
70
        $this->setTestResult($testResult);
71
    }
72
}
73