Passed
Branch master (4b23d6)
by Tim
04:40
created

Sql   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A invokeTest() 0 16 1
A __construct() 0 6 1
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\TestSuite\Store;
4
5
use SimpleSAML\Module\Monitor\TestConfiguration;
6
use SimpleSAML\Module\Monitor\TestCase;
7
use SimpleSAML\Module\Monitor\TestData;
8
use SimpleSAML\Module\Monitor\TestResult;
9
use SimpleSAML\Module\Monitor\State;
10
11
final class Sql extends \SimpleSAML\Module\Monitor\TestSuiteFactory
12
{
13
    /** var string */
14
    private $host;
15
16
17
    /**
18
     * @param \SimpleSAML\Module\Monitor\TestConfiguration $configuration
19
     */
20
    public function __construct(TestConfiguration $configuration)
21
    {
22
        $globalConfig = $configuration->getGlobalConfig();
23
        $this->host = $globalConfig->getString('store.sql.dsn');
24
25
        parent::__construct($configuration);
26
    }
27
28
29
    /**
30
     * @return void
31
     */
32
    public function invokeTest(): void
33
    {
34
        $testResult = new TestResult('SQL', 'Overall health');
35
36
        $input = [
37
            'host' => $this->host,
38
        ];
39
        $testData = new TestData($input);
40
        $test = new TestCase\Store\Sql($testData);
41
42
        $sqlResult = $test->getTestResult();
43
        $this->addTestResult($sqlResult);
44
45
        $state = $this->calculateState();
46
        $testResult->setState($state);
47
        $this->setTestResult($testResult);
48
    }
49
}
50