1 | <?php |
||
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 | { |
||
79 |
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.