Completed
Push — master ( bd69b1...b47d34 )
by nicolas
05:24 queued 02:30
created

SqlScriptCache::getProductUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dekalee\AdbackAnalytics\Driver;
4
5
/**
6
 * Class SqlScriptCache
7
 */
8
abstract class SqlScriptCache
9
{
10
    const ADBACK_ANALYTICS_SCRIPT = 'adback_analytics_script';
11
    const ADBACK_ANALYTICS_URL = 'adback_analytics_url';
12
    const ADBACK_MESSAGE_SCRIPT = 'adback_message_script';
13
    const ADBACK_MESSAGE_URL = 'adback_message_url';
14
    const ADBACK_AUTOPROMO_BANNER_SCRIPT = 'adback_autopromo_banner_script';
15
    const ADBACK_AUTOPROMO_BANNER_URL = 'adback_autopromo_banner_url';
16
    const ADBACK_PRODUCT_SCRIPT = 'adback_product_script';
17
    const ADBACK_PRODUCT_URL = 'adback_product_url';
18
19
    /**
20
     * @return bool
21
     */
22
    public function isAnalyticsConfigured()
23
    {
24
        return null != $this->get(self::ADBACK_ANALYTICS_SCRIPT);
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->get(self::ADBACK_ANALYTICS_SCRIPT) of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
25
    }
26
27
    /**
28
     * @param string $domain
29
     */
30
    public function setAnalyticsUrl($domain)
31
    {
32
        $this->set(self::ADBACK_ANALYTICS_URL, $domain);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getAnalyticsUrl()
39
    {
40
        return $this->get(self::ADBACK_ANALYTICS_URL);
41
    }
42
43
    /**
44
     * @param string $script
45
     */
46
    public function setAnalyticsScript($script)
47
    {
48
        $this->set(self::ADBACK_ANALYTICS_SCRIPT, $script);
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getAnalyticsScript()
55
    {
56
        return $this->get(self::ADBACK_ANALYTICS_SCRIPT);
57
    }
58
59
    /**
60
     * @return bool
61
     */
62
    public function isMessageConfigured()
63
    {
64
        return null != $this->get(self::ADBACK_MESSAGE_SCRIPT);
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->get(self::ADBACK_MESSAGE_SCRIPT) of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
65
    }
66
67
    /**
68
     * @return bool
69
     */
70
    public function isAutopromoBannerConfigured()
71
    {
72
        return null != $this->get(self::ADBACK_AUTOPROMO_BANNER_SCRIPT);
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->get(self::ADBACK_AUTOPROMO_BANNER_SCRIPT) of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
73
    }
74
75
    /**
76
     * @param string $domain
77
     */
78
    public function setMessageUrl($domain)
79
    {
80
        $this->set(self::ADBACK_MESSAGE_URL, $domain);
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getMessageUrl()
87
    {
88
        return $this->get(self::ADBACK_MESSAGE_URL);
89
    }
90
91
    /**
92
     * @param string $script
93
     */
94
    public function setMessageScript($script)
95
    {
96
        $this->set(self::ADBACK_MESSAGE_SCRIPT, $script);
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getMessageScript()
103
    {
104
        return $this->get(self::ADBACK_MESSAGE_SCRIPT);
105
    }
106
107
    /**
108
     * @param string $domain
109
     */
110
    public function setAutopromoBannerUrl($domain)
111
    {
112
        $this->set(self::ADBACK_AUTOPROMO_BANNER_URL, $domain);
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getAutopromoBannerUrl()
119
    {
120
        return $this->get(self::ADBACK_AUTOPROMO_BANNER_URL);
121
    }
122
123
    /**
124
     * @param string $domain
125
     */
126
    public function setProductUrl($domain)
127
    {
128
        $this->set(self::ADBACK_PRODUCT_URL, $domain);
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    public function getProductUrl()
135
    {
136
        return $this->get(self::ADBACK_PRODUCT_URL);
137
    }
138
139
    /**
140
     * @param string $script
141
     */
142
    public function setAutopromoBannerScript($script)
143
    {
144
        $this->set(self::ADBACK_AUTOPROMO_BANNER_SCRIPT, $script);
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getAutopromoBannerScript()
151
    {
152
        return $this->get(self::ADBACK_AUTOPROMO_BANNER_SCRIPT);
153
    }
154
155
    /**
156
     * @param string $script
157
     */
158
    public function setProductScript($script)
159
    {
160
        $this->set(self::ADBACK_PRODUCT_SCRIPT, $script);
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function getProductScript()
167
    {
168
        return $this->get(self::ADBACK_PRODUCT_SCRIPT);
169
    }
170
171
    /**
172
     * Clear analytics data
173
     */
174
    public function clearAnalyticsData()
175
    {
176
        $this->clear(self::ADBACK_ANALYTICS_SCRIPT);
177
        $this->clear(self::ADBACK_ANALYTICS_URL);
178
    }
179
180
    /**
181
     * Clear message data
182
     */
183
    public function clearMessageData()
184
    {
185
        $this->clear(self::ADBACK_MESSAGE_SCRIPT);
186
        $this->clear(self::ADBACK_MESSAGE_URL);
187
    }
188
189
    /**
190
     * Clear autopromo banner data
191
     */
192
    public function clearAutopromoBannerData()
193
    {
194
        $this->clear(self::ADBACK_AUTOPROMO_BANNER_SCRIPT);
195
        $this->clear(self::ADBACK_AUTOPROMO_BANNER_URL);
196
    }
197
198
    /**
199
     * Clear autopromo banner data
200
     */
201
    public function clearProductData()
202
    {
203
        $this->clear(self::ADBACK_PRODUCT_SCRIPT);
204
        $this->clear(self::ADBACK_PRODUCT_URL);
205
    }
206
207
    /**
208
     * @param string $key
209
     *
210
     * @return string|null
211
     */
212
    abstract protected function get($key);
213
214
    /**
215
     * @param string $key
216
     * @param string $value
217
     */
218
    abstract protected function set($key, $value);
219
220
    /**
221
     * @param string $key
222
     */
223
    abstract protected function clear($key);
224
}
225