@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | public function digit(string $data) |
46 | 46 | { |
47 | - if ( false == ctype_digit($data) ) { |
|
47 | + if (false == ctype_digit($data)) { |
|
48 | 48 | return "Your string " . $data . " must be a digit"; |
49 | 49 | } |
50 | 50 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function text() |
152 | 152 | { |
153 | 153 | if (!is_string($this->_postData[$this->_currentItem])) { |
154 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Text'); |
|
154 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Text'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $this; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | { |
162 | 162 | $email = filter_var($this->_postData[$this->_currentItem], FILTER_SANITIZE_EMAIL); |
163 | 163 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
164 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Email'); |
|
164 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Email'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return $this; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | public function numeric() |
171 | 171 | { |
172 | 172 | if (!is_numeric($this->_postData[$this->_currentItem])) { |
173 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Numeric'); |
|
173 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Numeric'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return $this; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | public function int() |
180 | 180 | { |
181 | 181 | if (!intval($this->_postData[$this->_currentItem])) { |
182 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Int'); |
|
182 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Int'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $this; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | public function long() |
189 | 189 | { |
190 | 190 | if (!floatval($this->_postData[$this->_currentItem])) { |
191 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Long'); |
|
191 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Long'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return $this; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function domain() |
198 | 198 | { |
199 | 199 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_DOMAIN)) { |
200 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Domain'); |
|
200 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Domain'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $this; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | public function url() |
207 | 207 | { |
208 | 208 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_URL)) { |
209 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Url'); |
|
209 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Url'); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | return $this; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function ip() |
216 | 216 | { |
217 | 217 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_IP)) { |
218 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Ip'); |
|
218 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Ip'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $this; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function date() |
225 | 225 | { |
226 | 226 | if (!is_string($this->_postData[$this->_currentItem])) { |
227 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Date'); |
|
227 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Date'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return $this; |
@@ -26,8 +26,8 @@ |
||
26 | 26 | /** |
27 | 27 | * @param string $message |
28 | 28 | */ |
29 | - public function write( $message, string $type = null) |
|
29 | + public function write($message, string $type = null) |
|
30 | 30 | { |
31 | - return $this->message =$message; |
|
31 | + return $this->message = $message; |
|
32 | 32 | } |
33 | 33 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | namespace Ballybran\Helpers\Log; |
19 | 19 | |
20 | 20 | |
21 | -class FileLoggerFactory implements iLoggerFactory{ |
|
21 | +class FileLoggerFactory implements iLoggerFactory { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @var string |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | private $filePath; |
27 | 27 | private $dir; |
28 | 28 | |
29 | - public function __construct(string $filePath, $dir= null) |
|
29 | + public function __construct(string $filePath, $dir = null) |
|
30 | 30 | { |
31 | 31 | if ($dir != null) { |
32 | 32 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | namespace Ballybran\Helpers\Log; |
20 | 20 | |
21 | 21 | |
22 | -interface iLogger{ |
|
22 | +interface iLogger { |
|
23 | 23 | |
24 | - public function write( $message, string $type = null); |
|
24 | + public function write($message, string $type = null); |
|
25 | 25 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | namespace Ballybran\Helpers\Log; |
20 | 20 | |
21 | -class StdoutLoggerFactory implements iLoggerFactory{ |
|
21 | +class StdoutLoggerFactory implements iLoggerFactory { |
|
22 | 22 | |
23 | 23 | |
24 | 24 | public function createLogger(): iLogger |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | public function ipToHex($ipAddress) |
170 | 170 | { |
171 | 171 | $hex = ''; |
172 | - if ( false !== strpos($ipAddress, ',') ) { |
|
172 | + if (false !== strpos($ipAddress, ',')) { |
|
173 | 173 | $splitIp = explode(',', $ipAddress); |
174 | 174 | $ipAddress = trim($splitIp[0]); |
175 | 175 | } |
176 | 176 | $isIpV6 = false; |
177 | 177 | $isIpV4 = false; |
178 | - if ( false !== filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { |
|
178 | + if (false !== filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
|
179 | 179 | $isIpV6 = true; |
180 | - } else if (false !== filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ) { |
|
180 | + } else if (false !== filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
181 | 181 | $isIpV4 = true; |
182 | 182 | } |
183 | 183 | if (!$isIpV4 && !$isIpV6) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | else { |
196 | 196 | $parts = explode(':', $ipAddress); |
197 | 197 | // If this is mixed IPv6/IPv4, convert end to IPv6 value |
198 | - if ( false !== filter_var($parts[count($parts) - 1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ) { |
|
198 | + if (false !== filter_var($parts[count($parts) - 1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
199 | 199 | $partsV4 = explode('.', $parts[count($parts) - 1]); |
200 | 200 | for ($i = 0; $i < 4; $i++) { |
201 | 201 | $partsV4[$i] = str_pad(dechex($partsV4[$i]), 2, '0', STR_PAD_LEFT); |
@@ -240,11 +240,18 @@ discard block |
||
240 | 240 | $QRange1 = $temp[0]; |
241 | 241 | $QRange2 = $temp[1]; |
242 | 242 | |
243 | - if ($QRange2 == "") return array($QRange1); //special case, they didn't put a second quad parameter |
|
243 | + if ($QRange2 == "") { |
|
244 | + return array($QRange1); |
|
245 | + } |
|
246 | + //special case, they didn't put a second quad parameter |
|
244 | 247 | |
245 | 248 | //basic error handling to see if it is generally a valid IP in the form N.N.N.N |
246 | - if (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $QRange1) != 1) return array(-1); |
|
247 | - if (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $QRange2) != 1) return array(-1); |
|
249 | + if (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $QRange1) != 1) { |
|
250 | + return array(-1); |
|
251 | + } |
|
252 | + if (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $QRange2) != 1) { |
|
253 | + return array(-1); |
|
254 | + } |
|
248 | 255 | |
249 | 256 | $quad1 = explode(".", $QRange1); |
250 | 257 | $quad2 = explode(".", $QRange2); |
@@ -252,12 +259,16 @@ discard block |
||
252 | 259 | reset($quad1); |
253 | 260 | while (list ($key, $val) = each($quad1)) { |
254 | 261 | $quad1[$key] = intval($val); |
255 | - if ($quad1[$key] < 0 || $quad1[$key] > 255) return array(-2); |
|
262 | + if ($quad1[$key] < 0 || $quad1[$key] > 255) { |
|
263 | + return array(-2); |
|
264 | + } |
|
256 | 265 | } |
257 | 266 | reset($quad2); |
258 | 267 | while (list ($key, $val) = each($quad2)) { |
259 | 268 | $quad2[$key] = intval($val); |
260 | - if ($quad2[$key] < 0 || $quad2[$key] > 255) return array(-2); |
|
269 | + if ($quad2[$key] < 0 || $quad2[$key] > 255) { |
|
270 | + return array(-2); |
|
271 | + } |
|
261 | 272 | } |
262 | 273 | |
263 | 274 | $startIP_long = sprintf("%u", ip2long($QRange1)); |
@@ -272,8 +283,9 @@ discard block |
||
272 | 283 | |
273 | 284 | //this is a total hack. there must be a better way. |
274 | 285 | $thisQuad = explode(".", $temp); |
275 | - if ($thisQuad[3] > 0 && $thisQuad[3] < 255) |
|
276 | - $ip[$k++] = $temp; |
|
286 | + if ($thisQuad[3] > 0 && $thisQuad[3] < 255) { |
|
287 | + $ip[$k++] = $temp; |
|
288 | + } |
|
277 | 289 | } |
278 | 290 | |
279 | 291 | return $ip; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | curl_setopt($curl, CURLOPT_POST, true); |
86 | 86 | curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); |
87 | 87 | $curl_response = curl_exec($curl); |
88 | - if ( false === $curl_response ) { |
|
88 | + if (false === $curl_response) { |
|
89 | 89 | $info = curl_getinfo($curl); |
90 | 90 | curl_close($curl); |
91 | 91 | die('error occured during curl exec. Additioanl info: ' . var_export($info)); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $data = array("status" => 'R'); |
108 | 108 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); |
109 | 109 | $response = curl_exec($ch); |
110 | - if ( false === $response ) { |
|
110 | + if (false === $response) { |
|
111 | 111 | $info = curl_getinfo($ch); |
112 | 112 | curl_close($ch); |
113 | 113 | die('error occured during curl exec. Additioanl info: ' . var_export($info)); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ); |
136 | 136 | curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post_data); |
137 | 137 | $curl_response = curl_exec($ch); |
138 | - if ( false === $curl_response ) { |
|
138 | + if (false === $curl_response) { |
|
139 | 139 | $info = curl_getinfo($ch); |
140 | 140 | curl_close($ch); |
141 | 141 | die('error occured during curl exec. Additioanl info: ' . var_export($info)); |
@@ -257,7 +257,7 @@ |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | public function setValue($value){ |
260 | - $this->data['value']= $value; |
|
260 | + $this->data['value']= $value; |
|
261 | 261 | |
262 | 262 | } |
263 | 263 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return Cookie |
60 | 60 | */ |
61 | - public function createCookie( $name, int $maxage = 0, string $path = '', string $domain = '', bool $secure = false,bool $HTTPOnly = false): Cookie |
|
61 | + public function createCookie($name, int $maxage = 0, string $path = '', string $domain = '', bool $secure = false, bool $HTTPOnly = false): Cookie |
|
62 | 62 | { |
63 | 63 | $this->setName($name) |
64 | 64 | ->setMaxage($maxage) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $ob = ini_get('output_buffering'); |
76 | 76 | |
77 | 77 | // Abort the method if headers have already been sent, except when output buffering has been enabled |
78 | - if (headers_sent() && false === (bool)$ob || 'off' == strtolower($ob) ) { |
|
78 | + if (headers_sent() && false === (bool)$ob || 'off' == strtolower($ob)) { |
|
79 | 79 | return $this; |
80 | 80 | } |
81 | 81 | |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function setName($name) : Cookie |
131 | 131 | { |
132 | - if(is_array($name)) { |
|
132 | + if (is_array($name)) { |
|
133 | 133 | |
134 | 134 | foreach ($name as $k => $v) { |
135 | 135 | $this->data['name'] = $k . '=' . rawurlencode($v); |
136 | 136 | } |
137 | - }else { |
|
138 | - $this->data['name'] = $name . '='. rawurlencode($name); |
|
137 | + } else { |
|
138 | + $this->data['name'] = $name . '=' . rawurlencode($name); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $this; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | // Remove port information. |
190 | 190 | $port = strpos($domain, ':'); |
191 | - if ( false !== $port ) { |
|
191 | + if (false !== $port) { |
|
192 | 192 | $this->data['domain'] = substr($domain, 0, $port); |
193 | 193 | } |
194 | 194 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | return $this->data['value']; |
257 | 257 | } |
258 | 258 | |
259 | - public function setValue($value){ |
|
260 | - $this->data['value']= $value; |
|
259 | + public function setValue($value) { |
|
260 | + $this->data['value'] = $value; |
|
261 | 261 | |
262 | 262 | } |
263 | 263 |
@@ -134,7 +134,7 @@ |
||
134 | 134 | foreach ($name as $k => $v) { |
135 | 135 | $this->data['name'] = $k . '=' . rawurlencode($v); |
136 | 136 | } |
137 | - }else { |
|
137 | + } else { |
|
138 | 138 | $this->data['name'] = $name . '='. rawurlencode($name); |
139 | 139 | } |
140 | 140 |