Passed
Push — master ( bb5c60...87d27f )
by Tim
01:35
created

Sql   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 4 1
A invokeTest() 0 14 2
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\TestCase\Store;
4
5
use \SimpleSAML\Modules\Monitor\State as State;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\Modules\Monitor\State was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use \SimpleSAML\Modules\Monitor\TestData as TestData;
7
use \SimpleSAML\Modules\Monitor\TestResult as TestResult;
8
9
final class Sql extends \SimpleSAML\Modules\Monitor\TestCaseFactory
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $host;
15
16
    /**
17
     * @param TestData $testData
18
     *
19
     * @return void
20
     */
21
    protected function initialize($testData)
22
    {
23
        $this->host = $testData->getInputItem('host');
24
        parent::initialize($testData);
25
    }
26
27
    /**
28
     * @return void
29
     */
30
    public function invokeTest()
31
    {
32
        $testResult = new TestResult('SQL Server Health', $this->host);
33
34
        try {
35
            new \SimpleSAML\Store\SQL();
36
            $testResult->setState(State::OK);
37
            $testResult->setMessage('Connection to the database succesfully established');
38
        } catch (\Exception $e) {
39
            $testResult->setState(State::FATAL);
40
            $testResult->setMessage('Unable to connect to the database; '.$e->getMessage());
41
        }
42
43
        $this->setTestResult($testResult);
44
    }
45
}
46