Test Failed
Push — master ( b2d464...e1b9bb )
by Erandir
02:06
created
src/Utils/ArrayUtil.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@
 block discarded – undo
27 27
 		return $array;
28 28
 	}
29 29
 
30
-    public static function converToObject(array $data)
31
-    {
32
-        $object = new \stdClass();
30
+	public static function converToObject(array $data)
31
+	{
32
+		$object = new \stdClass();
33 33
 
34
-        foreach ($data as $key => $value) {
35
-            $object->$key = $value;
36
-        }
34
+		foreach ($data as $key => $value) {
35
+			$object->$key = $value;
36
+		}
37 37
 
38
-        return $object;
38
+		return $object;
39 39
 	}
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/Globals/Get.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@
 block discarded – undo
54 54
 		return $this;
55 55
 	}
56 56
 
57
-    private function set(string $key, $value)
58
-    {
59
-        $_GET[$key] = $value;
60
-    }
57
+	private function set(string $key, $value)
58
+	{
59
+		$_GET[$key] = $value;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
src/Globals/Env.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@
 block discarded – undo
54 54
 		return $this;
55 55
 	}
56 56
 
57
-    private function set(string $key, $value)
58
-    {
59
-        $_ENV[$key] = $value;
60
-    }
57
+	private function set(string $key, $value)
58
+	{
59
+		$_ENV[$key] = $value;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
src/Globals/Cookie.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@
 block discarded – undo
49 49
 	{
50 50
 		unset($this->cookie[$key]);
51 51
 
52
-        unset($_COOKIE[$key]);
52
+		unset($_COOKIE[$key]);
53 53
 
54
-        return $this;
54
+		return $this;
55 55
 	}
56 56
 
57 57
 	private function set(string $key, $value, $expire, $path, $domain, $secure, $httponly)
Please login to merge, or discard this patch.
src/Globals/GlobalRequest.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 	private Server $server;
17 17
 
18 18
 	public function __construct(
19
-        Content $body,
20
-        Get $get,
21
-        File $file,
22
-        Server $server
19
+		Content $body,
20
+		Get $get,
21
+		File $file,
22
+		Server $server
23 23
 	)
24 24
 	{
25
-        $this->body 	= $body->getBodyRequest();
26
-        $this->get 		= $get;
27
-        $this->server	= $server;
25
+		$this->body 	= $body->getBodyRequest();
26
+		$this->get 		= $get;
27
+		$this->server	= $server;
28 28
 		$this->file 	= $file;
29 29
 	}
30 30
 
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	public function bodyObject()
37 37
 	{
38 38
 		if (is_array($this->body)) {
39
-            return ArrayUtil::converToObject($this->body);
40
-        }
39
+			return ArrayUtil::converToObject($this->body);
40
+		}
41 41
 
42 42
 		if (is_object($this->body)) {
43
-		    return $this->body;
44
-        }
43
+			return $this->body;
44
+		}
45 45
 
46 46
 		throw new \Exception("It wasn't possible convert to object");
47 47
 	}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
 	{
25 25
         $this->body 	= $body->getBodyRequest();
26 26
         $this->get 		= $get;
27
-        $this->server	= $server;
28
-		$this->file 	= $file;
27
+        $this->server = $server;
28
+		$this->file = $file;
29 29
 	}
30 30
 
31 31
 	public function all()
Please login to merge, or discard this patch.
src/Globals/Server.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -63,56 +63,56 @@
 block discarded – undo
63 63
 
64 64
 	public function getContent()
65 65
 	{
66
-        if (!empty($_POST)) {
67
-            return $_POST;
68
-        }
66
+		if (!empty($_POST)) {
67
+			return $_POST;
68
+		}
69 69
 
70 70
 		return file_get_contents("php://input");
71 71
 	}
72 72
 
73
-    public function get(string $key)
74
-    {
75
-        return $this->server[$key];
76
-    }
73
+	public function get(string $key)
74
+	{
75
+		return $this->server[$key];
76
+	}
77 77
 
78
-    public function all(): array
79
-    {
80
-        return $this->server;
81
-    }
78
+	public function all(): array
79
+	{
80
+		return $this->server;
81
+	}
82 82
 
83
-    public function except(array $keys): array
84
-    {
85
-        return ArrayUtil::except($this->server, $keys);
86
-    }
83
+	public function except(array $keys): array
84
+	{
85
+		return ArrayUtil::except($this->server, $keys);
86
+	}
87 87
 
88
-    public function only(array $keys): array
89
-    {
90
-        return ArrayUtil::only($this->server, $keys);
91
-    }
88
+	public function only(array $keys): array
89
+	{
90
+		return ArrayUtil::only($this->server, $keys);
91
+	}
92 92
 
93
-    public function has(string $key): bool
94
-    {
95
-        return !empty($this->server[$key]);
96
-    }
93
+	public function has(string $key): bool
94
+	{
95
+		return !empty($this->server[$key]);
96
+	}
97 97
 
98
-    public function add($key, $value): void
99
-    {
100
-        $this->server[$key] = $value;
98
+	public function add($key, $value): void
99
+	{
100
+		$this->server[$key] = $value;
101 101
 
102
-        $this->set($key, $value);
103
-    }
102
+		$this->set($key, $value);
103
+	}
104 104
 
105
-    public function remove(string $key): Server
106
-    {
107
-        unset($this->server[$key]);
105
+	public function remove(string $key): Server
106
+	{
107
+		unset($this->server[$key]);
108 108
 
109
-        unset($_SERVER[$key]);
109
+		unset($_SERVER[$key]);
110 110
 
111
-        return $this;
112
-    }
111
+		return $this;
112
+	}
113 113
 
114
-    private function set(string $key, $value)
115
-    {
116
-        $_SERVER[$key] = $value;
117
-    }
114
+	private function set(string $key, $value)
115
+	{
116
+		$_SERVER[$key] = $value;
117
+	}
118 118
 }
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@
 block discarded – undo
19 19
 	protected function clearHeadersFromHeadersList($headers, $needle)
20 20
 	{
21 21
 		foreach ($headers as $header) {
22
-			if(stripos($header,$needle) !== false) {
23
-				$headerParts = explode(':',$header);
22
+			if (stripos($header, $needle) !== false) {
23
+				$headerParts = explode(':', $header);
24 24
 				return trim($headerParts[1]);
25 25
 			}
26 26
 		}
Please login to merge, or discard this patch.
src/Globals/Session.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@
 block discarded – undo
49 49
 	{
50 50
 		unset($this->session[$key]);
51 51
 
52
-        unset($_SESSION[$key]);
52
+		unset($_SESSION[$key]);
53 53
 
54
-        return $this;
54
+		return $this;
55 55
 	}
56 56
 
57
-    private function set(string $key, $value)
58
-    {
59
-        $_SESSION[$key] = $value;
60
-    }
57
+	private function set(string $key, $value)
58
+	{
59
+		$_SESSION[$key] = $value;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
src/Request.php 1 patch
Indentation   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -16,496 +16,496 @@
 block discarded – undo
16 16
  */
17 17
 class Request
18 18
 {
19
-    /**
20
-     * @var Cookie
21
-     */
22
-    private Cookie $cookie;
23
-
24
-    /**
25
-     * @var Env
26
-     */
27
-    private Env $env;
28
-
29
-    /**
30
-     * @var File
31
-     */
32
-    private File $file;
33
-
34
-    /**
35
-     * @var Get
36
-     */
37
-    private Get $get;
38
-
39
-    /**
40
-     * @var Server
41
-     */
42
-    private Server $server;
43
-
44
-    /**
45
-     * @var Session
46
-     */
47
-    private Session $session;
48
-
49
-    /**
50
-     * @var Content
51
-     */
52
-    private Content $content;
53
-
54
-    /**
55
-     * Request constructor.
56
-     */
57
-    public function __construct()
58
-    {
59
-        $this->cookie = new Cookie();
60
-        $this->env = new Env();
61
-        $this->file = new File();
62
-        $this->get = new Get();
63
-        $this->server = new Server();
64
-        $this->session = new Session();
65
-        $this->content = new Content($this->server);
66
-    }
67
-
68
-    /**
69
-     * @param string $key
70
-     * @param $value
71
-     */
72
-    public function addCookie(string $key, $value, $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false): void
73
-    {
74
-        $this->cookie->add($key, $value, $expire, $path, $domain, $secure, $httponly);
75
-    }
76
-
77
-    /**
78
-     * @param string|null $key
79
-     * @return array|mixed
80
-     */
81
-    public function cookies(?string $key = null)
82
-    {
83
-        if ($key) {
84
-            return $this->cookie->get($key);
85
-        }
86
-
87
-        return $this->cookie->all();
88
-    }
89
-
90
-    /**
91
-     * @param $key
92
-     * @return bool
93
-     */
94
-    public function hasCookie($key): bool
95
-    {
96
-        return $this->cookie->has($key);
97
-    }
98
-
99
-    /**
100
-     * @param $key
101
-     */
102
-    public function removeCookie($key): void
103
-    {
104
-        $this->cookie->remove($key);
105
-    }
106
-
107
-    /**
108
-     * @param array $values
109
-     * @return array
110
-     */
111
-    public function exceptCookie(array $values): array
112
-    {
113
-        return $this->cookie->except($values);
114
-    }
115
-
116
-    /**
117
-     * @param array $values
118
-     * @return array
119
-     */
120
-    public function onlyCookie(array $values): array
121
-    {
122
-        return $this->cookie->only($values);
123
-    }
124
-
125
-    /**
126
-     * @param string|null $key
127
-     * @return array|mixed
128
-     */
129
-    public function query(?string $key = null)
130
-    {
131
-        if ($key) {
132
-            return $this->get->get($key);
133
-        }
134
-
135
-        return $this->get->all();
136
-    }
137
-
138
-    /**
139
-     * @param string $key
140
-     * @param $value
141
-     */
142
-    public function addQuery(string $key, $value): void
143
-    {
144
-        $this->get->add($key, $value);
145
-    }
146
-
147
-    /**
148
-     * @param array $values
149
-     * @return array
150
-     */
151
-    public function onlyQuery(array $values): array
152
-    {
153
-        return $this->get->only($values);
154
-    }
155
-
156
-    /**
157
-     * @param array $values
158
-     * @return array
159
-     */
160
-    public function exceptQuery(array $values): array
161
-    {
162
-        return $this->get->except($values);
163
-    }
164
-
165
-    /**
166
-     * @param string $value
167
-     * @return bool
168
-     */
169
-    public function hasQuery(string $value): bool
170
-    {
171
-        return $this->get->has($value);
172
-    }
173
-
174
-    /**
175
-     * @param string $key
176
-     */
177
-    public function removeQuery(string $key): void
178
-    {
179
-        $this->get->remove($key);
180
-    }
181
-
182
-    /**
183
-     * @param string|null $key
184
-     * @return array|mixed
185
-     */
186
-    public function env(?string $key = null)
187
-    {
188
-        if ($key) {
189
-            return $this->env->get($key);
190
-        }
191
-
192
-        return $this->env->all();
193
-    }
194
-
195
-    /**
196
-     * @param string $key
197
-     * @param $value
198
-     */
199
-    public function addEnv(string $key, $value): void
200
-    {
201
-        $this->env->add($key, $value);
202
-    }
203
-
204
-    /**
205
-     * @param array $values
206
-     * @return array
207
-     */
208
-    public function onlyEnv(array $values): array
209
-    {
210
-        return $this->env->only($values);
211
-    }
212
-
213
-    /**
214
-     * @param array $values
215
-     * @return array
216
-     */
217
-    public function exceptEnv(array $values): array
218
-    {
219
-        return $this->env->except($values);
220
-    }
221
-
222
-    /**
223
-     * @param string $value
224
-     * @return bool
225
-     */
226
-    public function hasEnv(string $value): bool
227
-    {
228
-        return $this->env->has($value);
229
-    }
230
-
231
-    /**
232
-     * @param string $key
233
-     */
234
-    public function removeEnv(string $key): void
235
-    {
236
-        $this->env->remove($key);
237
-    }
238
-
239
-    /**
240
-     * @param string|null $key
241
-     * @return array
242
-     */
243
-    public function file(?string $key = null)
244
-    {
245
-        if ($key) {
246
-            return $this->file->get($key);
247
-        }
248
-
249
-        return $this->file->all();
250
-    }
251
-
252
-    /**
253
-     * @param $key
254
-     * @return bool
255
-     */
256
-    public function hasFile($key): bool
257
-    {
258
-        return $this->file->has($key);
259
-    }
260
-
261
-    /**
262
-     * @param $key
263
-     */
264
-    public function removeFile($key): void
265
-    {
266
-        $this->file->remove($key);
267
-    }
268
-
269
-    /**
270
-     * @param array $values
271
-     * @return array
272
-     */
273
-    public function exceptFile(array $values): array
274
-    {
275
-        return $this->file->except($values);
276
-    }
277
-
278
-    /**
279
-     * @param array $values
280
-     * @return array
281
-     */
282
-    public function onlyFile(array $values): array
283
-    {
284
-        return $this->file->only($values);
285
-    }
286
-
287
-    /**
288
-     * @param string $key
289
-     * @param $value
290
-     */
291
-    public function addHeader(string $key, $value): void
292
-    {
293
-        $this->server->add($key, $value);
294
-    }
295
-
296
-    /**
297
-     * @param string $key
298
-     * @return array|mixed
299
-     */
300
-    public function header(string $key)
301
-    {
302
-        return $this->server->get($key);
303
-    }
304
-
305
-    /**
306
-     * @param $key
307
-     * @return bool
308
-     */
309
-    public function hasheader($key): bool
310
-    {
311
-        return $this->server->has($key);
312
-    }
313
-
314
-    /**
315
-     * @param $key
316
-     */
317
-    public function removeHeader($key): void
318
-    {
319
-        $this->server->remove($key);
320
-    }
321
-
322
-    /**
323
-     * @param array $values
324
-     * @return array
325
-     */
326
-    public function exceptHeaders(array $values): array
327
-    {
328
-        return $this->server->except($values);
329
-    }
330
-
331
-    /**
332
-     * @param array $values
333
-     * @return array
334
-     */
335
-    public function onlyHeaders(array $values): array
336
-    {
337
-        return $this->server->only($values);
338
-    }
339
-
340
-    /**
341
-     * @return string
342
-     */
343
-    public function method(): string
344
-    {
345
-        return $this->server->method();
346
-    }
347
-
348
-    /**
349
-     * @return string
350
-     */
351
-    public function getUrl(): string
352
-    {
353
-        return $this->server->getUrl();
354
-    }
355
-
356
-    /**
357
-     * @param string $method
358
-     * @return bool
359
-     */
360
-    public function isMethod(string $method): bool
361
-    {
362
-        return $this->method() === strtoupper($method);
363
-    }
364
-
365
-    /**
366
-     * @return array
367
-     */
368
-    public function headers(): array
369
-    {
370
-        return $this->server->all();
371
-    }
372
-
373
-    /**
374
-     * @param string $path
375
-     * @param int $code
376
-     * @return bool
377
-     */
378
-    public function redirect(string $path, int $code = 301)
379
-    {
380
-        header("HTTP/1.0 {$code}");
381
-        header("Location: {$path}");
382
-
383
-        return true;
384
-    }
385
-
386
-    /**
387
-     * @param string $key
388
-     * @param $value
389
-     */
390
-    public function addSession(string $key, $value): void
391
-    {
392
-        $this->session->add($key, $value);
393
-    }
394
-
395
-    /**
396
-     * @param string|null $key
397
-     * @return array|mixed
398
-     */
399
-    public function session(?string $key = null)
400
-    {
401
-        if ($key) {
402
-            return $this->session->get($key);
403
-        }
404
-
405
-        return $this->session->all();
406
-    }
407
-
408
-    /**
409
-     * @param $key
410
-     * @return bool
411
-     */
412
-    public function hasSession($key): bool
413
-    {
414
-        return $this->session->has($key);
415
-    }
416
-
417
-    /**
418
-     * @param $key
419
-     */
420
-    public function removeSession($key): void
421
-    {
422
-        $this->session->remove($key);
423
-    }
424
-
425
-    /**
426
-     * @param array $values
427
-     * @return array
428
-     */
429
-    public function exceptSession(array $values): array
430
-    {
431
-        return $this->session->except($values);
432
-    }
433
-
434
-    /**
435
-     * @param array $values
436
-     * @return array
437
-     */
438
-    public function onlySession(array $values): array
439
-    {
440
-        return $this->session->only($values);
441
-    }
442
-
443
-    /**
444
-     * @param array $values
445
-     * @return array
446
-     */
447
-    public function except(array $values)
448
-    {
449
-        return $this->content->except($values);
450
-    }
451
-
452
-    /**
453
-     * @param array $values
454
-     * @return array
455
-     */
456
-    public function only(array $values)
457
-    {
458
-        return $this->content->only($values);
459
-    }
460
-
461
-    /**
462
-     * @param string $key
463
-     * @return bool
464
-     */
465
-    public function has(string $key): bool
466
-    {
467
-        return $this->content->has($key);
468
-    }
469
-
470
-    /**
471
-     * @param string $key
472
-     */
473
-    public function remove(string $key): void
474
-    {
475
-        $this->content->remove($key);
476
-    }
477
-
478
-    /**
479
-     * @param $key
480
-     * @param $value
481
-     */
482
-    public function add($key, $value)
483
-    {
484
-        $this->content->add($key, $value);
485
-    }
486
-
487
-    /**
488
-     * @return array
489
-     */
490
-    public function all(): array
491
-    {
492
-        return $this->content->all();
493
-    }
494
-
495
-    /**
496
-     * @param string $value
497
-     * @return mixed
498
-     */
499
-    public function get(string $value)
500
-    {
501
-        return $this->content->get($value);
502
-    }
503
-
504
-    /**
505
-     * @param $name
506
-     */
507
-    public function __get($name)
508
-    {
509
-        return $this->content->$name;
510
-    }
19
+	/**
20
+	 * @var Cookie
21
+	 */
22
+	private Cookie $cookie;
23
+
24
+	/**
25
+	 * @var Env
26
+	 */
27
+	private Env $env;
28
+
29
+	/**
30
+	 * @var File
31
+	 */
32
+	private File $file;
33
+
34
+	/**
35
+	 * @var Get
36
+	 */
37
+	private Get $get;
38
+
39
+	/**
40
+	 * @var Server
41
+	 */
42
+	private Server $server;
43
+
44
+	/**
45
+	 * @var Session
46
+	 */
47
+	private Session $session;
48
+
49
+	/**
50
+	 * @var Content
51
+	 */
52
+	private Content $content;
53
+
54
+	/**
55
+	 * Request constructor.
56
+	 */
57
+	public function __construct()
58
+	{
59
+		$this->cookie = new Cookie();
60
+		$this->env = new Env();
61
+		$this->file = new File();
62
+		$this->get = new Get();
63
+		$this->server = new Server();
64
+		$this->session = new Session();
65
+		$this->content = new Content($this->server);
66
+	}
67
+
68
+	/**
69
+	 * @param string $key
70
+	 * @param $value
71
+	 */
72
+	public function addCookie(string $key, $value, $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false): void
73
+	{
74
+		$this->cookie->add($key, $value, $expire, $path, $domain, $secure, $httponly);
75
+	}
76
+
77
+	/**
78
+	 * @param string|null $key
79
+	 * @return array|mixed
80
+	 */
81
+	public function cookies(?string $key = null)
82
+	{
83
+		if ($key) {
84
+			return $this->cookie->get($key);
85
+		}
86
+
87
+		return $this->cookie->all();
88
+	}
89
+
90
+	/**
91
+	 * @param $key
92
+	 * @return bool
93
+	 */
94
+	public function hasCookie($key): bool
95
+	{
96
+		return $this->cookie->has($key);
97
+	}
98
+
99
+	/**
100
+	 * @param $key
101
+	 */
102
+	public function removeCookie($key): void
103
+	{
104
+		$this->cookie->remove($key);
105
+	}
106
+
107
+	/**
108
+	 * @param array $values
109
+	 * @return array
110
+	 */
111
+	public function exceptCookie(array $values): array
112
+	{
113
+		return $this->cookie->except($values);
114
+	}
115
+
116
+	/**
117
+	 * @param array $values
118
+	 * @return array
119
+	 */
120
+	public function onlyCookie(array $values): array
121
+	{
122
+		return $this->cookie->only($values);
123
+	}
124
+
125
+	/**
126
+	 * @param string|null $key
127
+	 * @return array|mixed
128
+	 */
129
+	public function query(?string $key = null)
130
+	{
131
+		if ($key) {
132
+			return $this->get->get($key);
133
+		}
134
+
135
+		return $this->get->all();
136
+	}
137
+
138
+	/**
139
+	 * @param string $key
140
+	 * @param $value
141
+	 */
142
+	public function addQuery(string $key, $value): void
143
+	{
144
+		$this->get->add($key, $value);
145
+	}
146
+
147
+	/**
148
+	 * @param array $values
149
+	 * @return array
150
+	 */
151
+	public function onlyQuery(array $values): array
152
+	{
153
+		return $this->get->only($values);
154
+	}
155
+
156
+	/**
157
+	 * @param array $values
158
+	 * @return array
159
+	 */
160
+	public function exceptQuery(array $values): array
161
+	{
162
+		return $this->get->except($values);
163
+	}
164
+
165
+	/**
166
+	 * @param string $value
167
+	 * @return bool
168
+	 */
169
+	public function hasQuery(string $value): bool
170
+	{
171
+		return $this->get->has($value);
172
+	}
173
+
174
+	/**
175
+	 * @param string $key
176
+	 */
177
+	public function removeQuery(string $key): void
178
+	{
179
+		$this->get->remove($key);
180
+	}
181
+
182
+	/**
183
+	 * @param string|null $key
184
+	 * @return array|mixed
185
+	 */
186
+	public function env(?string $key = null)
187
+	{
188
+		if ($key) {
189
+			return $this->env->get($key);
190
+		}
191
+
192
+		return $this->env->all();
193
+	}
194
+
195
+	/**
196
+	 * @param string $key
197
+	 * @param $value
198
+	 */
199
+	public function addEnv(string $key, $value): void
200
+	{
201
+		$this->env->add($key, $value);
202
+	}
203
+
204
+	/**
205
+	 * @param array $values
206
+	 * @return array
207
+	 */
208
+	public function onlyEnv(array $values): array
209
+	{
210
+		return $this->env->only($values);
211
+	}
212
+
213
+	/**
214
+	 * @param array $values
215
+	 * @return array
216
+	 */
217
+	public function exceptEnv(array $values): array
218
+	{
219
+		return $this->env->except($values);
220
+	}
221
+
222
+	/**
223
+	 * @param string $value
224
+	 * @return bool
225
+	 */
226
+	public function hasEnv(string $value): bool
227
+	{
228
+		return $this->env->has($value);
229
+	}
230
+
231
+	/**
232
+	 * @param string $key
233
+	 */
234
+	public function removeEnv(string $key): void
235
+	{
236
+		$this->env->remove($key);
237
+	}
238
+
239
+	/**
240
+	 * @param string|null $key
241
+	 * @return array
242
+	 */
243
+	public function file(?string $key = null)
244
+	{
245
+		if ($key) {
246
+			return $this->file->get($key);
247
+		}
248
+
249
+		return $this->file->all();
250
+	}
251
+
252
+	/**
253
+	 * @param $key
254
+	 * @return bool
255
+	 */
256
+	public function hasFile($key): bool
257
+	{
258
+		return $this->file->has($key);
259
+	}
260
+
261
+	/**
262
+	 * @param $key
263
+	 */
264
+	public function removeFile($key): void
265
+	{
266
+		$this->file->remove($key);
267
+	}
268
+
269
+	/**
270
+	 * @param array $values
271
+	 * @return array
272
+	 */
273
+	public function exceptFile(array $values): array
274
+	{
275
+		return $this->file->except($values);
276
+	}
277
+
278
+	/**
279
+	 * @param array $values
280
+	 * @return array
281
+	 */
282
+	public function onlyFile(array $values): array
283
+	{
284
+		return $this->file->only($values);
285
+	}
286
+
287
+	/**
288
+	 * @param string $key
289
+	 * @param $value
290
+	 */
291
+	public function addHeader(string $key, $value): void
292
+	{
293
+		$this->server->add($key, $value);
294
+	}
295
+
296
+	/**
297
+	 * @param string $key
298
+	 * @return array|mixed
299
+	 */
300
+	public function header(string $key)
301
+	{
302
+		return $this->server->get($key);
303
+	}
304
+
305
+	/**
306
+	 * @param $key
307
+	 * @return bool
308
+	 */
309
+	public function hasheader($key): bool
310
+	{
311
+		return $this->server->has($key);
312
+	}
313
+
314
+	/**
315
+	 * @param $key
316
+	 */
317
+	public function removeHeader($key): void
318
+	{
319
+		$this->server->remove($key);
320
+	}
321
+
322
+	/**
323
+	 * @param array $values
324
+	 * @return array
325
+	 */
326
+	public function exceptHeaders(array $values): array
327
+	{
328
+		return $this->server->except($values);
329
+	}
330
+
331
+	/**
332
+	 * @param array $values
333
+	 * @return array
334
+	 */
335
+	public function onlyHeaders(array $values): array
336
+	{
337
+		return $this->server->only($values);
338
+	}
339
+
340
+	/**
341
+	 * @return string
342
+	 */
343
+	public function method(): string
344
+	{
345
+		return $this->server->method();
346
+	}
347
+
348
+	/**
349
+	 * @return string
350
+	 */
351
+	public function getUrl(): string
352
+	{
353
+		return $this->server->getUrl();
354
+	}
355
+
356
+	/**
357
+	 * @param string $method
358
+	 * @return bool
359
+	 */
360
+	public function isMethod(string $method): bool
361
+	{
362
+		return $this->method() === strtoupper($method);
363
+	}
364
+
365
+	/**
366
+	 * @return array
367
+	 */
368
+	public function headers(): array
369
+	{
370
+		return $this->server->all();
371
+	}
372
+
373
+	/**
374
+	 * @param string $path
375
+	 * @param int $code
376
+	 * @return bool
377
+	 */
378
+	public function redirect(string $path, int $code = 301)
379
+	{
380
+		header("HTTP/1.0 {$code}");
381
+		header("Location: {$path}");
382
+
383
+		return true;
384
+	}
385
+
386
+	/**
387
+	 * @param string $key
388
+	 * @param $value
389
+	 */
390
+	public function addSession(string $key, $value): void
391
+	{
392
+		$this->session->add($key, $value);
393
+	}
394
+
395
+	/**
396
+	 * @param string|null $key
397
+	 * @return array|mixed
398
+	 */
399
+	public function session(?string $key = null)
400
+	{
401
+		if ($key) {
402
+			return $this->session->get($key);
403
+		}
404
+
405
+		return $this->session->all();
406
+	}
407
+
408
+	/**
409
+	 * @param $key
410
+	 * @return bool
411
+	 */
412
+	public function hasSession($key): bool
413
+	{
414
+		return $this->session->has($key);
415
+	}
416
+
417
+	/**
418
+	 * @param $key
419
+	 */
420
+	public function removeSession($key): void
421
+	{
422
+		$this->session->remove($key);
423
+	}
424
+
425
+	/**
426
+	 * @param array $values
427
+	 * @return array
428
+	 */
429
+	public function exceptSession(array $values): array
430
+	{
431
+		return $this->session->except($values);
432
+	}
433
+
434
+	/**
435
+	 * @param array $values
436
+	 * @return array
437
+	 */
438
+	public function onlySession(array $values): array
439
+	{
440
+		return $this->session->only($values);
441
+	}
442
+
443
+	/**
444
+	 * @param array $values
445
+	 * @return array
446
+	 */
447
+	public function except(array $values)
448
+	{
449
+		return $this->content->except($values);
450
+	}
451
+
452
+	/**
453
+	 * @param array $values
454
+	 * @return array
455
+	 */
456
+	public function only(array $values)
457
+	{
458
+		return $this->content->only($values);
459
+	}
460
+
461
+	/**
462
+	 * @param string $key
463
+	 * @return bool
464
+	 */
465
+	public function has(string $key): bool
466
+	{
467
+		return $this->content->has($key);
468
+	}
469
+
470
+	/**
471
+	 * @param string $key
472
+	 */
473
+	public function remove(string $key): void
474
+	{
475
+		$this->content->remove($key);
476
+	}
477
+
478
+	/**
479
+	 * @param $key
480
+	 * @param $value
481
+	 */
482
+	public function add($key, $value)
483
+	{
484
+		$this->content->add($key, $value);
485
+	}
486
+
487
+	/**
488
+	 * @return array
489
+	 */
490
+	public function all(): array
491
+	{
492
+		return $this->content->all();
493
+	}
494
+
495
+	/**
496
+	 * @param string $value
497
+	 * @return mixed
498
+	 */
499
+	public function get(string $value)
500
+	{
501
+		return $this->content->get($value);
502
+	}
503
+
504
+	/**
505
+	 * @param $name
506
+	 */
507
+	public function __get($name)
508
+	{
509
+		return $this->content->$name;
510
+	}
511 511
 }
512 512
\ No newline at end of file
Please login to merge, or discard this patch.
src/Response.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class Response
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    private array $headers;
15
-
16
-    /**
17
-     * @var int
18
-     */
19
-    private int $statusCode;
20
-
21
-    /**
22
-     * Response constructor.
23
-     */
24
-    public function __construct()
25
-    {
26
-        $this->headers = [];
27
-        $this->statusCode = 200;
28
-    }
29
-
30
-    /**
31
-     * @param array $headers
32
-     * @return $this
33
-     */
34
-    public function addHeaders(array $headers): Response
11
+	/**
12
+	 * @var array
13
+	 */
14
+	private array $headers;
15
+
16
+	/**
17
+	 * @var int
18
+	 */
19
+	private int $statusCode;
20
+
21
+	/**
22
+	 * Response constructor.
23
+	 */
24
+	public function __construct()
25
+	{
26
+		$this->headers = [];
27
+		$this->statusCode = 200;
28
+	}
29
+
30
+	/**
31
+	 * @param array $headers
32
+	 * @return $this
33
+	 */
34
+	public function addHeaders(array $headers): Response
35 35
 	{
36 36
 		foreach ($headers as $v) {
37 37
 			$this->headers[] = $v;
@@ -40,49 +40,49 @@  discard block
 block discarded – undo
40 40
 		return $this;
41 41
 	}
42 42
 
43
-    /**
44
-     * @param string $header
45
-     * @param mixed $value
46
-     * @return $this
47
-     */
48
-    public function addHeader(string $header, mixed $value): Response
43
+	/**
44
+	 * @param string $header
45
+	 * @param mixed $value
46
+	 * @return $this
47
+	 */
48
+	public function addHeader(string $header, mixed $value): Response
49 49
 	{
50
-        $this->headers[$header] = $value;
50
+		$this->headers[$header] = $value;
51 51
 
52 52
 		return $this;
53 53
 	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getHeaders(): array
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getHeaders(): array
59 59
 	{
60 60
 		return $this->headers;
61 61
 	}
62 62
 
63
-    /**
64
-     * @param int $statusCode
65
-     * @return $this
66
-     */
67
-    public function setStatusCode(int $statusCode): Response
63
+	/**
64
+	 * @param int $statusCode
65
+	 * @return $this
66
+	 */
67
+	public function setStatusCode(int $statusCode): Response
68 68
 	{
69 69
 		$this->statusCode = $statusCode;
70 70
 
71 71
 		return $this;
72 72
 	}
73 73
 
74
-    /**
75
-     * @return int
76
-     */
77
-    public function getStatusCode(): int
74
+	/**
75
+	 * @return int
76
+	 */
77
+	public function getStatusCode(): int
78 78
 	{
79 79
 		return $this->statusCode;
80 80
 	}
81 81
 
82
-    /**
83
-     * @return $this
84
-     */
85
-    public function response(): Response
82
+	/**
83
+	 * @return $this
84
+	 */
85
+	public function response(): Response
86 86
 	{
87 87
 		foreach ($this->headers as $k => $v) {
88 88
 			header("{$v}");
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 		return $this;
94 94
 	}
95 95
 
96
-    /**
97
-     * @param array $data
98
-     * @return false|string
99
-     */
100
-    public function json(array $data)
96
+	/**
97
+	 * @param array $data
98
+	 * @return false|string
99
+	 */
100
+	public function json(array $data)
101 101
 	{
102 102
 		header("Content-type: application/json");
103 103
 
Please login to merge, or discard this patch.