Passed
Push — master ( 4d841d...d5e097 )
by Gabor
04:40
created

AbstractAdapter::getSelectedApplication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
crap 1
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2017 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 $mainDomain;
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 1
    public function getApplicationRoot(): string
94
    {
95 1
        return $this->applicationRoot;
96
    }
97
98
    /**
99
     * Gets the application domain.
100
     *
101
     * @return string
102
     */
103 9
    public function getApplicationDomain() : string
104
    {
105 9
        return $this->applicationDomain;
106
    }
107
108
    /**
109
     * Gets the application SSL status.
110
     *
111
     * @return bool
112
     */
113 10
    public function isSecuredApplication() : bool
114
    {
115 10
        return $this->isHttps;
116
    }
117
118
    /**
119
     * Gets the selected application.
120
     *
121
     * @return string
122
     */
123 17
    public function getSelectedApplication() : string
124
    {
125 17
        return $this->selectedApplication;
126
    }
127
128
    /**
129
     * Get the URI path for the selected application. Required for the RouterAdapter to work with directory-based
130
     * applications correctly.
131
     *
132
     * @return string
133
     */
134 17
    public function getSelectedApplicationUri() : string
135
    {
136 17
        return $this->selectedApplicationUri;
137
    }
138
139
    /**
140
     * Gets the request URI
141
     *
142
     * @return string
143
     */
144
    abstract public function getRequestUri() : string;
145
146
    /**
147
     * Gets the selected module.
148
     *
149
     * @return string
150
     */
151 17
    public function getSelectedModule() : string
152
    {
153 17
        return $this->selectedModule;
154
    }
155
156
    /**
157
     * Gets the selected theme.
158
     *
159
     * @return string
160
     */
161 11
    public function getSelectedTheme() : string
162
    {
163 11
        return $this->selectedTheme;
164
    }
165
166
    /**
167
     * Gets the resource path for the selected theme.
168
     *
169
     * @return string
170
     */
171 2
    public function getResourcePath() : string
172
    {
173 2
        return $this->selectedThemeResourcePath;
174
    }
175
176
    /**
177
     * Gets the request method.
178
     *
179
     * @return string
180
     */
181
    abstract public function getRequestMethod(): string;
182
183
    /**
184
     * Gets environment data.
185
     *
186
     * @param string $key
187
     * @return array
188
     */
189
    abstract public function getEnvironmentData(string $key) : array;
190
191
    /**
192
     * Gets the client IP address.
193
     *
194
     * @return string
195
     */
196
    abstract public function getClientIp() : string;
197
198
    /**
199
     * Gets the execution parameters (CLI).
200
     *
201
     * @return array
202
     */
203 1
    public function getOptions() : array
204
    {
205 1
        return $this->options;
206
    }
207
}
208