Passed
Branch monitor-2.5.x (74d2b5)
by Tim
02:19
created

Sql   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A invokeTest() 0 16 1
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\TestSuite\Store;
4
5
use \SimpleSAML\Modules\Monitor\TestConfiguration as TestConfiguration;
6
use \SimpleSAML\Modules\Monitor\TestCase as TestCase;
7
use \SimpleSAML\Modules\Monitor\TestData as TestData;
8
use \SimpleSAML\Modules\Monitor\TestResult as TestResult;
9
use \SimpleSAML\Modules\Monitor\State as State;
10
11
final class Sql extends \SimpleSAML\Modules\Monitor\TestSuiteFactory
12
{
13
    /**
14
     * var string
15
     */
16
    private $host;
17
18
    /**
19
     * @param TestConfiguration $configuration
20
     */
21
    public function __construct($configuration)
22
    {
23
        $globalConfig = $configuration->getGlobalConfig();
24
        $this->host = $globalConfig->getString('store.sql.dsn');
25
26
        parent::__construct($configuration);
27
    }
28
29
    /**
30
     * @return void
31
     */
32
    public function invokeTest()
33
    {
34
        $testResult = new TestResult('SQL', 'Overall health');
35
36
        $input = array(
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