Completed
Push — master ( b067c2...abcd9a )
by Tim
05:48
created

Configuration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 63
rs 10
c 2
b 0
f 0
wmc 5
lcom 1
cbo 7
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 8.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace SimpleSAML\Module\monitor\TestSuite;
4
5
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration;
6
use \SimpleSAML\Module\monitor\TestCase as TestCase;
7
use \SimpleSAML\Module\monitor\TestData as TestData;
8
user \SimpleSAML\Utils as Utils;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_AS
Loading history...
9
10
final class Configuration extends \SimpleSAML\Module\monitor\TestSuiteFactory
11
{
12
    /**
13
     * @param string|null
14
     */
15
    private $metadataCert = null;
16
17
    /**
18
     * @param string|null;
19
     */
20
    private $serverName = null;
21
22
    /**
23
     * @param integer|null;
24
     */
25
    private $serverPort = null;
26
27
    /**
28
     * @param TestConfiguration $configuration
29
     */
30
    public function __construct($configuration)
31
    {
32
        $globalConfig = $configuration->getGlobalConfig();
33
        $this->metadataCert = $globalConfig->getString('metadata.sign.certificate', null);
34
        $this->serverName = Utils\HTTP::getSelfHost();
35
        $this->serverPort = Utils\HTTP::getServerPort();
36
37
        parent::__construct($configuration);
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    protected function invokeTestSuite()
44
    {
45
        // Check Service Communications Certificate
46
        if (Utils\HTTP::isHTTPS()) {
47
            $input = array(
48
                'category' => 'Service Communications Certificate',
49
                'hostname' => $this->serverName,
50
                'port' => $this->serverPort
51
            );
52
            $testData = new TestData($input);
53
54
            $test = new TestCase\Cert\Remote($this, $testData);
55
            $this->addTest($test);
56
        }
57
58
        // Check metadata signing certificate when available
59
        if (is_string($this->metadataCert)) {
60
            $input = array(
61
                'certFile' => Utils\Config::getCertPath($this->metadataCert),
62
                'category' => 'Metadata Signing Certificate'
63
            );
64
            $testData = new TestData($input);
65
66
            $test = new TestCase\Cert\File($this, $testData);
67
            $this->addTest($test);
68
        }
69
70
        $tests = $this->getTests();
71
        foreach ($tests as $test)
72
        {
73
            $this->addMessages($test->getMessages());
74
        }
75
76
        $this->calculateState();
77
    }
78
}
79