Completed
Branch feature-unit-tests (9d0273)
by Tim
01:44
created

Store::invokeTest()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 30
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 15
nc 5
nop 0
dl 0
loc 30
rs 8.5806
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor\TestSuite;
4
5
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration;
6
use \SimpleSAML\Module\monitor\State as State;
7
use \SimpleSAML\Module\monitor\TestData as TestData;
8
use \SimpleSAML\Logger as Logger;
9
10
final class Store extends \SimpleSAML\Module\monitor\TestSuiteFactory
11
{
12
    /**
13
     * var string|null
14
     */
15
    private $store = null;
16
17
    /**
18
     * @param TestConfiguration $configuration
19
     */
20
    public function __construct($configuration)
21
    {
22
        $globalConfig = $configuration->getGlobalConfig();
23
        $this->store = $globalConfig->getString('store.type', 'phpsession');
24
        $this->setCategory('Session store');
25
26
        parent::__construct($configuration);
27
    }
28
29
    /**
30
     * @return void
31
     */
32
    public function invokeTest()
33
    {
34
        $configuration = $this->getConfiguration();
35
36
        switch ($this->store) {
37
            case 'phpsession':
38
                $test = new Store\Phpsession($configuration);
39
                break;
40
            case 'memcache':
41
                $test = new Store\Memcache($configuration);
42
                break;
43
// TODO:
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
//            case 'redis':
45
//            case 'redissentinel':
46
//                $test = new Store\Redis($configuration);
47
//                break;
48
//            case 'sql':
49
//                $test = new Store\Sql($configuration);
50
//                break;
51
            default:
52
                Logger::warning("Not implemented;  $this->store - Skipping Store TestSuite.");
53
                return;
54
        }
55
56
        $results = $test->getTestResults();
57
        foreach ($results as $result) {
58
            $this->addTestResult($result);
59
        }
60
61
        $this->calculateState();
62
    }
63
}
64