Passed
Push — master ( 7f7c15...e5d3ba )
by Jonathan
05:04 queued 02:53
created

Sdk::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Tisd\Sdk;
4
5
use Tisd\Sdk\Defaults\Defaults;
6
use Tisd\Sdk\Cache\Cache;
7
8
class Sdk
9
{
10
    use ConsolidatedTrait;
11
    use ContextsTrait;
12
    use FilterTrait;
13
    use LocalesTrait;
14
    use MetaTrait;
15
    use PackagesTrait;
16
    use PackageTrait;
17
18
    protected $cache;
19
20
    protected $context;
21
22
    protected $hostname;
23
24
    protected $locale;
25
26
    protected $timeout;
27
28
    protected $version;
29
30
    public function test()
31
    {
32
        return 'hello world';
33
    }
34
35
36 45
    public function __construct($options = [])
37
    {
38 45
        $defaults = new Defaults();
39
40
        $optionKeys = [
41 45
            'context',
42
            'hostname',
43
            'locale',
44
            'timeout',
45
            'version',
46
        ];
47
48 45
        foreach ($optionKeys as $optionKey) {
49 45
            if (array_key_exists($optionKey, $options)) {
50 1
                $value = $options[$optionKey];
51
            } else {
52 45
                $getter = sprintf('get%s', ucfirst($optionKey));
53 45
                $value  = $defaults->$getter();
54
            }
55
56 45
            $setter = sprintf('set%s', ucfirst($optionKey));
57 45
            $this->$setter($value);
58
        }
59
60 45
        $cache = new Cache();
61
62 45
        $this->setCache($cache);
63 45
    }
64
65 39
    public function getCache()
66
    {
67 39
        return $this->cache;
68
    }
69
70 45
    public function setCache(Cache $cache)
71
    {
72 45
        $this->cache = $cache;
73
74 45
        return $this;
75
    }
76
77 40
    public function getContext()
78
    {
79 40
        return $this->context;
80
    }
81
82 45
    public function setContext($context)
83
    {
84 45
        $this->context = $context;
85
86 45
        return $this;
87
    }
88
89 7
    public function getHostname()
90
    {
91 7
        return $this->hostname;
92
    }
93
94 45
    public function setHostname($hostname)
95
    {
96 45
        $this->hostname = $hostname;
97
98 45
        return $this;
99
    }
100
101 40
    public function getLocale()
102
    {
103 40
        return $this->locale;
104
    }
105
106 45
    public function setLocale($locale)
107
    {
108 45
        $this->locale = $locale;
109
110 45
        return $this;
111
    }
112
113 7
    public function getTimeout()
114
    {
115 7
        return $this->timeout;
116
    }
117
118 45
    public function setTimeout($timeout)
119
    {
120 45
        $this->timeout = $timeout;
121
122 45
        return $this;
123
    }
124
125 7
    public function getVersion()
126
    {
127 7
        return $this->version;
128
    }
129
130 45
    public function setVersion($version)
131
    {
132 45
        $this->version = $version;
133
134 45
        return $this;
135
    }
136
}
137