Completed
Push — master ( f60e47...74fc93 )
by Sandro
02:28
created

UniversalContainerIdConfiguration::getData()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 15
nc 5
nop 1
1
<?php
2
/**
3
 * Sandro Keil (https://sandro-keil.de)
4
 *
5
 * @link      http://github.com/sandrokeil/interop-config for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 Sandro Keil
7
 * @license   http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
8
 */
9
10
namespace InteropTest\Config\TestAsset;
11
12
use Interop\Config\ConfigurationTrait;
13
use Interop\Config\ProvidesDefaultOptions;
14
use Interop\Config\RequiresConfigId;
15
use Interop\Config\RequiresMandatoryOptions;
16
17
class UniversalContainerIdConfiguration implements RequiresConfigId, ProvidesDefaultOptions, RequiresMandatoryOptions
18
{
19
    use ConfigurationTrait;
20
21
    const TYPE_ARRAY_ITERATOR = 0;
22
    const TYPE_ARRAY_OBJECT = 1;
23
    const TYPE_ARRAY_ARRAY = 2;
24
    const TYPE_ONLY_ITERATOR = 3;
25
26
    private static $dimensions = [
27
        'doctrine',
28
        'universal',
29
    ];
30
31
    private static $mandatoryOptions = [
32
        'params' => ['user', 'dbname'],
33
        'driverClass',
34
    ];
35
36
    private static $defaultOptions = [
37
        'params' => [
38
            'host' => 'awesomehost',
39
            'port' => '4444',
40
        ],
41
    ];
42
43
    private $type;
44
45
    public function __construct(int $type)
46
    {
47
        $this->type = $type;
48
    }
49
50
    public function dimensions(): iterable
51
    {
52
        return $this->getData('dimensions');
53
    }
54
55
    public function mandatoryOptions(): iterable
56
    {
57
        return $this->getData('mandatoryOptions');
58
    }
59
60
    public function defaultOptions(): iterable
61
    {
62
        return $this->getData('defaultOptions');
63
    }
64
65
    private function getData($name)
66
    {
67
        switch ($this->type) {
68
            case self::TYPE_ARRAY_ITERATOR:
69
                return new \ArrayIterator(self::$$name);
70
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
71
            case self::TYPE_ARRAY_OBJECT:
72
                return new \ArrayObject(self::$$name);
73
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
74
            case self::TYPE_ONLY_ITERATOR:
75
                return new OnlyIterator(self::$$name);
76
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
77
            case self::TYPE_ARRAY_ARRAY:
78
            default:
79
                return self::$$name;
80
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
81
        }
82
    }
83
}
84