Configuration::invokeTest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\monitor\TestSuite;
6
7
use SimpleSAML\Module\monitor\TestConfiguration;
8
use SimpleSAML\Module\monitor\TestCase;
9
use SimpleSAML\Module\monitor\TestData;
10
use SimpleSAML\Module\monitor\TestResult;
11
use SimpleSAML\Module\monitor\State;
12
use SimpleSAML\Utils;
13
14
final class Configuration extends \SimpleSAML\Module\monitor\TestSuiteFactory
15
{
16
    /**
17
     * @param \SimpleSAML\Module\monitor\TestConfiguration $configuration
18
     */
19
    public function __construct(TestConfiguration $configuration)
20
    {
21
        $this->setCategory('Configuration');
22
        parent::__construct($configuration);
23
    }
24
25
26
    /**
27
     * @param \SimpleSAML\Module\monitor\TestConfiguration $configuration
28
     * @return array
29
     */
30
    private function testCertificates(TestConfiguration $configuration): array
31
    {
32
        $test = new Configuration\Certificates($configuration);
33
        return $test->getTestResults();
34
    }
35
36
37
    /**
38
     * @param \SimpleSAML\Module\monitor\TestConfiguration $configuration
39
     * @return array
40
     */
41
    private function testDatabase(TestConfiguration $configuration): array
42
    {
43
        $test = new Configuration\Database($configuration);
44
        return $test->getTestResults();
45
    }
46
47
48
    /**
49
     * @return void
50
     */
51
    public function invokeTest(): void
52
    {
53
        $configuration = $this->getConfiguration();
54
        $results = [];
55
56
        $results = array_merge($results, $this->testCertificates($configuration));
57
        $results = array_merge($results, $this->testDatabase($configuration));
58
59
        foreach ($results as $result) {
60
            $this->addTestResult($result);
61
        }
62
        $this->calculateState();
63
    }
64
}
65