Sql::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\monitor\TestSuite\Store;
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
13
final class Sql extends \SimpleSAML\Module\monitor\TestSuiteFactory
14
{
15
    /** var string */
16
    private string $host;
17
18
19
    /**
20
     * @param \SimpleSAML\Module\monitor\TestConfiguration $configuration
21
     */
22
    public function __construct(TestConfiguration $configuration)
23
    {
24
        $globalConfig = $configuration->getGlobalConfig();
25
        $this->host = $globalConfig->getString('store.sql.dsn');
26
27
        parent::__construct($configuration);
28
    }
29
30
31
    /**
32
     * @return void
33
     */
34
    public function invokeTest(): void
35
    {
36
        $testResult = new TestResult('SQL', 'Overall health');
37
38
        $input = [
39
            'host' => $this->host,
40
        ];
41
        $testData = new TestData($input);
42
        $test = new TestCase\Store\Sql($testData);
43
44
        $sqlResult = $test->getTestResult();
45
        $this->addTestResult($sqlResult);
46
47
        $state = $this->calculateState();
48
        $testResult->setState($state);
49
        $this->setTestResult($testResult);
50
    }
51
}
52