Passed
Push — master ( 6282ae...86ce5d )
by Gabor
04:01
created

AbstractAdapter   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 205
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
lcom 0
cbo 0
dl 0
loc 205
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
__construct() 0 9 ?
A getDocumentRoot() 0 4 1
A getApplicationRoot() 0 4 1
A getApplicationDomain() 0 4 1
A getTopDomain() 0 4 1
A isSecuredApplication() 0 4 1
A getSelectedApplication() 0 4 1
A getSelectedApplicationUri() 0 4 1
A getAddress() 0 4 1
getRequestUri() 0 1 ?
A getSelectedModule() 0 4 1
A getSelectedTheme() 0 4 1
A getResourcePath() 0 4 1
getRequestMethod() 0 1 ?
getEnvironmentData() 0 1 ?
getClientIp() 0 1 ?
A getOptions() 0 4 1
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Environment;
15
16
use Exception;
17
use WebHemi\Configuration\ServiceInterface as ConfigurationInterface;
18
19
/**
20
 * Class AbstractAdapter.
21
 * @SuppressWarnings(PHPMD.TooManyFields)
22
 */
23
abstract class AbstractAdapter implements ServiceInterface
24
{
25
    /** @var ConfigurationInterface */
26
    protected $configuration;
27
    /** @var string */
28
    protected $url;
29
    /** @var string */
30
    protected $subDomain;
31
    /** @var string */
32
    protected $topDomain;
33
    /** @var string */
34
    protected $applicationDomain;
35
    /** @var string */
36
    protected $documentRoot;
37
    /** @var string */
38
    protected $applicationRoot;
39
    /** @var string */
40
    protected $selectedModule;
41
    /** @var string */
42
    protected $selectedApplication;
43
    /** @var string */
44
    protected $selectedApplicationUri;
45
    /** @var string */
46
    protected $selectedTheme;
47
    /** @var string */
48
    protected $selectedThemeResourcePath;
49
    /** @var array  */
50
    protected $environmentData;
51
    /** @var bool */
52
    protected $isHttps;
53
    /** @var array */
54
    protected $options = [];
55
56
    /**
57
     * ServiceAdapter constructor.
58
     *
59
     * @param ConfigurationInterface $configuration
60
     * @param array                  $getData
61
     * @param array                  $postData
62
     * @param array                  $serverData
63
     * @param array                  $cookieData
64
     * @param array                  $filesData
65
     * @param array                  $optionsData
66
     * @throws Exception
67
     */
68
    abstract public function __construct(
69
        ConfigurationInterface $configuration,
70
        array $getData,
71
        array $postData,
72
        array $serverData,
73
        array $cookieData,
74
        array $filesData,
75
        array $optionsData
76
    );
77
78
    /**
79
     * Gets the document root path.
80
     *
81
     * @return string
82
     */
83 11
    public function getDocumentRoot() : string
84
    {
85 11
        return $this->documentRoot;
86
    }
87
88
    /**
89
     * Gets the application path.
90
     *
91
     * @return string
92
     */
93 6
    public function getApplicationRoot(): string
94
    {
95 6
        return $this->applicationRoot;
96
    }
97
98
    /**
99
     * Gets the application domain.
100
     *
101
     * @return string
102
     */
103 4
    public function getApplicationDomain() : string
104
    {
105 4
        return $this->applicationDomain;
106
    }
107
108
    /**
109
     * Gets the top domain.
110
     *
111
     * @return string
112
     */
113 3
    public function getTopDomain() : string
114
    {
115 3
        return $this->topDomain;
116
    }
117
118
    /**
119
     * Gets the application SSL status.
120
     *
121
     * @return bool
122
     */
123 19
    public function isSecuredApplication() : bool
124
    {
125 19
        return $this->isHttps;
126
    }
127
128
    /**
129
     * Gets the selected application.
130
     *
131
     * @return string
132
     */
133 26
    public function getSelectedApplication() : string
134
    {
135 26
        return $this->selectedApplication;
136
    }
137
138
    /**
139
     * Get the URI path for the selected application. Required for the RouterAdapter to work with directory-based
140
     * applications correctly.
141
     *
142
     * @return string
143
     */
144 18
    public function getSelectedApplicationUri() : string
145
    {
146 18
        return $this->selectedApplicationUri;
147
    }
148
149
    /**
150
     * Gets the full address
151
     *
152
     * @return string
153
     */
154 3
    public function getAddress() : string
155
    {
156 3
        return $this->url;
157
    }
158
159
    /**
160
     * Gets the request URI
161
     *
162
     * @return string
163
     */
164
    abstract public function getRequestUri() : string;
165
166
    /**
167
     * Gets the selected module.
168
     *
169
     * @return string
170
     */
171 18
    public function getSelectedModule() : string
172
    {
173 18
        return $this->selectedModule;
174
    }
175
176
    /**
177
     * Gets the selected theme.
178
     *
179
     * @return string
180
     */
181 11
    public function getSelectedTheme() : string
182
    {
183 11
        return $this->selectedTheme;
184
    }
185
186
    /**
187
     * Gets the resource path for the selected theme.
188
     *
189
     * @return string
190
     */
191 2
    public function getResourcePath() : string
192
    {
193 2
        return $this->selectedThemeResourcePath;
194
    }
195
196
    /**
197
     * Gets the request method.
198
     *
199
     * @return string
200
     */
201
    abstract public function getRequestMethod(): string;
202
203
    /**
204
     * Gets environment data.
205
     *
206
     * @param string $key
207
     * @return array
208
     */
209
    abstract public function getEnvironmentData(string $key) : array;
210
211
    /**
212
     * Gets the client IP address.
213
     *
214
     * @return string
215
     */
216
    abstract public function getClientIp() : string;
217
218
    /**
219
     * Gets the execution parameters (CLI).
220
     *
221
     * @return array
222
     */
223 1
    public function getOptions() : array
224
    {
225 1
        return $this->options;
226
    }
227
}
228