Completed
Push — master ( aa0024...ad4c83 )
by Tim
06:53 queued 05:29
created

sspmod_monitor_TestSuite_Configuration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 1 1
B invokeTestSuite() 0 37 4
1
<?php
2
3
final class sspmod_monitor_TestSuite_Configuration extends sspmod_monitor_TestSuite
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /*
6
     * @return void
7
     */
8
    protected function initialize() {}
9
10
    /*
11
     * @return void
12
     */
13
    protected function invokeTestSuite()
0 ignored issues
show
Coding Style introduced by
invokeTestSuite uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
14
    {
15
        $monitor = $this->getMonitor();
16
        $globalConfig = $monitor->getGlobalConfig();
17
        // Check Service Communications Certificate
18
        if (\SimpleSAML\Utils\HTTP::isHTTPS()) {
19
            $input = array(
20
                'category' => 'Service Communications Certificate',
21
                'hostname' => $_SERVER['SERVER_NAME'],
22
                'port' => $_SERVER['SERVER_PORT']
23
            );
24
25
            $test = new sspmod_monitor_TestCase_Cert_Remote($this, $input);
26
            $this->addTest($test);
27
        }
28
29
        // Check metadata signing certificate when available
30
        if ($globalConfig->hasValue('metadata.sign.certificate')) {
31
            $metadataCert = $globalConfig->getString('metadata.sign.certificate');
32
33
            $input = array(
34
                'certFile' => \SimpleSAML\Utils\Config::getCertPath($metadataCert),
35
                'category' => 'Metadata Signing Certificate'
36
            );
37
38
            $test = new sspmod_monitor_TestCase_Cert_File($this, $input);
39
            $this->addTest($test);
40
        }
41
42
        $tests = $this->getTests();
43
        foreach ($tests as $test)
44
        {
45
            $this->addMessages($test->getMessages());
46
        }
47
48
        $this->calculateState();
49
    }
50
}
51