Passed
Push — master ( 7c1ca3...71b9d8 )
by Alexander
19:53 queued 16:06
created
src/components/Http/Resources/HttpStatusCode.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -30,209 +30,209 @@
 block discarded – undo
30 30
  */
31 31
 trait HttpStatusCode
32 32
 {
33
-	/**
34
-	 * The HTTP status code.
35
-	 *
36
-	 * @var int $statusCode
37
-	 */
38
-	protected $statusCode = 200;
39
-
40
-	/**
41
-	 * An array of status codes and messages.
42
-	 *
43
-	 * @var array $statusCodeTexts
44
-	 */
45
-	public static $statusCodeTexts = [
46
-		// 1xx: Informational
47
-		100 => 'Continue',
48
-		101 => 'Switching Protocols',
49
-		102 => 'Processing',
50
-
51
-		// 2xx: Success
52
-		200 => 'OK',
53
-		201 => 'Created',
54
-		202 => 'Accepted',
55
-		203 => 'Non-Authoritative Information',
56
-		204 => 'No Content',
57
-		205 => 'Reset Content',
58
-		206 => 'Partial Content',
59
-		207 => 'Multi-Status',
60
-		208 => 'Already Reported',
61
-		226 => 'IM Used',
62
-
63
-		// 3xx: Redirection
64
-		300 => 'Multiple Choices',
65
-		301 => 'Moved Permanently',
66
-		302 => 'Found',
67
-		303 => 'See Other',
68
-		304 => 'Not Modified',
69
-		305 => 'Use Proxy',
70
-		307 => 'Temporary Redirect',
71
-		308 => 'Permanent Redirect',
72
-
73
-		// 4xx: Client error
74
-		400 => 'Bad Request',
75
-		401 => 'Unauthorized',
76
-		402 => 'Payment Required',
77
-		403 => 'Forbidden',
78
-		404 => 'Not Found',
79
-		405 => 'Method Not Allowed',
80
-		406 => 'Not Acceptable',
81
-		407 => 'Proxy Authentication Required',
82
-		408 => 'Request Timeout',
83
-		409 => 'Conflict',
84
-		410 => 'Gone',
85
-		411 => 'Length Required',
86
-		412 => 'Precondition Failed',
87
-		413 => 'Request Entity Too Large',
88
-		414 => 'Request-URI Too Long',
89
-		415 => 'Unsupported Media Type',
90
-		416 => 'Requested Range Not Satisfiable',
91
-		417 => 'Expectation Failed',
92
-		418 => 'I\'m a Teapot',
93
-		// 419 (Authentication Timeout) is a non-standard status code with unknown origin
94
-		421 => 'Misdirected Request',
95
-		422 => 'Unprocessable Entity',
96
-		423 => 'Locked',
97
-		424 => 'Failed Dependency',
98
-		426 => 'Upgrade Required',
99
-		428 => 'Precondition Required',
100
-		429 => 'Too Many Requests',
101
-		431 => 'Request Header Fields Too Large',
102
-		451 => 'Unavailable For Legal Reasons',
103
-
104
-		// 5xx: Server error
105
-		500 => 'Internal Server Error',
106
-		501 => 'Not Implemented',
107
-		502 => 'Bad Gateway',
108
-		503 => 'Service Unavailable',
109
-		504 => 'Gateway Timeout',
110
-		505 => 'HTTP Version Not Supported',
111
-		506 => 'Variant Also Negotiates',
112
-		507 => 'Insufficient Storage',
113
-		508 => 'Loop Detected',
114
-		509 => 'Bandwidth Limit Exceeded',
115
-		510 => 'Not Extended',
116
-		511 => 'Network Authentication Required'
117
-	];
118
-
119
-	/**
120
-	 * Gets string of status code.
121
-	 * 
122
-	 * @var string $statusText
123
-	 */
124
-	protected $statusText;
125
-
126
-	/**
127
-	 * Gets the response status code.
128
-	 *
129
-	 * The status code is a 3-digit code to specify server response results to the browser.
130
-	 *
131
-	 * @return int
132
-	 *
133
-	 * @throws \BadMethodCallException
134
-	 */
135
-	public function getStatusCode(): int
136
-	{
137
-		if (empty($this->statusCode)) {
138
-			throw new BadMethodCallException('HTTP Response is missing a status code');
139
-		}
140
-
141
-		return $this->statusCode;
142
-	}
143
-
144
-	/**
145
-	* Sets the response status code.
146
-	*
147
-	* @param  int  $code  The status code
148
-	* @param  string|null  $text  The status text
149
-	*
150
-	* @return static
151
-	*
152
-	* @throws \InvalidArgumentException
153
-	*/
154
-	public function setStatusCode(int $code, $text = null): static
155
-	{
156
-		$this->statusCode = $code; 
157
-
158
-		// Valid range?
159
-		if ($this->isInvalid()) {
160
-			throw new InvalidArgumentException(__('response.statusCodeNotValid', ['code' => $code]));			
161
-		}
162
-
163
-		// Check if you have an accepted status code if not shows to a message of unknown status
164
-		if (null === $text) {
165
-			$this->statusText = self::$statusCodeTexts[$code] ?? __('response.UnknownStatus');
166
-
167
-			return $this;
168
-		}
169
-
170
-		if (false === $text) {
171
-			$this->statusText = '';
172
-
173
-			return $this;
174
-		}
175
-
176
-		$this->statusText = $text;
177
-
178
-		return $this;
179
-	}
180
-
181
-	/**
182
-	 * Is response invalid?
183
-	 * 
184
-	 * @final
185
-	 * 
186
-	 * @return bool
187
-	 */
188
-	public function isInvalid(): bool
189
-	{
190
-		return $this->statusCode < 100 || $this->statusCode >= 600;
191
-	}
192
-
193
-	/**
194
-	 * Is response informative?
195
-	 * 
196
-	 * @final
197
-	 * 
198
-	 * @return bool
199
-	 */
200
-	public function isInformational(): bool
201
-	{
202
-		return $this->statusCode >= 100 && $this->statusCode < 200;
203
-	}
33
+    /**
34
+     * The HTTP status code.
35
+     *
36
+     * @var int $statusCode
37
+     */
38
+    protected $statusCode = 200;
39
+
40
+    /**
41
+     * An array of status codes and messages.
42
+     *
43
+     * @var array $statusCodeTexts
44
+     */
45
+    public static $statusCodeTexts = [
46
+        // 1xx: Informational
47
+        100 => 'Continue',
48
+        101 => 'Switching Protocols',
49
+        102 => 'Processing',
50
+
51
+        // 2xx: Success
52
+        200 => 'OK',
53
+        201 => 'Created',
54
+        202 => 'Accepted',
55
+        203 => 'Non-Authoritative Information',
56
+        204 => 'No Content',
57
+        205 => 'Reset Content',
58
+        206 => 'Partial Content',
59
+        207 => 'Multi-Status',
60
+        208 => 'Already Reported',
61
+        226 => 'IM Used',
62
+
63
+        // 3xx: Redirection
64
+        300 => 'Multiple Choices',
65
+        301 => 'Moved Permanently',
66
+        302 => 'Found',
67
+        303 => 'See Other',
68
+        304 => 'Not Modified',
69
+        305 => 'Use Proxy',
70
+        307 => 'Temporary Redirect',
71
+        308 => 'Permanent Redirect',
72
+
73
+        // 4xx: Client error
74
+        400 => 'Bad Request',
75
+        401 => 'Unauthorized',
76
+        402 => 'Payment Required',
77
+        403 => 'Forbidden',
78
+        404 => 'Not Found',
79
+        405 => 'Method Not Allowed',
80
+        406 => 'Not Acceptable',
81
+        407 => 'Proxy Authentication Required',
82
+        408 => 'Request Timeout',
83
+        409 => 'Conflict',
84
+        410 => 'Gone',
85
+        411 => 'Length Required',
86
+        412 => 'Precondition Failed',
87
+        413 => 'Request Entity Too Large',
88
+        414 => 'Request-URI Too Long',
89
+        415 => 'Unsupported Media Type',
90
+        416 => 'Requested Range Not Satisfiable',
91
+        417 => 'Expectation Failed',
92
+        418 => 'I\'m a Teapot',
93
+        // 419 (Authentication Timeout) is a non-standard status code with unknown origin
94
+        421 => 'Misdirected Request',
95
+        422 => 'Unprocessable Entity',
96
+        423 => 'Locked',
97
+        424 => 'Failed Dependency',
98
+        426 => 'Upgrade Required',
99
+        428 => 'Precondition Required',
100
+        429 => 'Too Many Requests',
101
+        431 => 'Request Header Fields Too Large',
102
+        451 => 'Unavailable For Legal Reasons',
103
+
104
+        // 5xx: Server error
105
+        500 => 'Internal Server Error',
106
+        501 => 'Not Implemented',
107
+        502 => 'Bad Gateway',
108
+        503 => 'Service Unavailable',
109
+        504 => 'Gateway Timeout',
110
+        505 => 'HTTP Version Not Supported',
111
+        506 => 'Variant Also Negotiates',
112
+        507 => 'Insufficient Storage',
113
+        508 => 'Loop Detected',
114
+        509 => 'Bandwidth Limit Exceeded',
115
+        510 => 'Not Extended',
116
+        511 => 'Network Authentication Required'
117
+    ];
118
+
119
+    /**
120
+     * Gets string of status code.
121
+     * 
122
+     * @var string $statusText
123
+     */
124
+    protected $statusText;
125
+
126
+    /**
127
+     * Gets the response status code.
128
+     *
129
+     * The status code is a 3-digit code to specify server response results to the browser.
130
+     *
131
+     * @return int
132
+     *
133
+     * @throws \BadMethodCallException
134
+     */
135
+    public function getStatusCode(): int
136
+    {
137
+        if (empty($this->statusCode)) {
138
+            throw new BadMethodCallException('HTTP Response is missing a status code');
139
+        }
140
+
141
+        return $this->statusCode;
142
+    }
143
+
144
+    /**
145
+     * Sets the response status code.
146
+     *
147
+     * @param  int  $code  The status code
148
+     * @param  string|null  $text  The status text
149
+     *
150
+     * @return static
151
+     *
152
+     * @throws \InvalidArgumentException
153
+     */
154
+    public function setStatusCode(int $code, $text = null): static
155
+    {
156
+        $this->statusCode = $code; 
157
+
158
+        // Valid range?
159
+        if ($this->isInvalid()) {
160
+            throw new InvalidArgumentException(__('response.statusCodeNotValid', ['code' => $code]));			
161
+        }
162
+
163
+        // Check if you have an accepted status code if not shows to a message of unknown status
164
+        if (null === $text) {
165
+            $this->statusText = self::$statusCodeTexts[$code] ?? __('response.UnknownStatus');
166
+
167
+            return $this;
168
+        }
169
+
170
+        if (false === $text) {
171
+            $this->statusText = '';
172
+
173
+            return $this;
174
+        }
175
+
176
+        $this->statusText = $text;
177
+
178
+        return $this;
179
+    }
180
+
181
+    /**
182
+     * Is response invalid?
183
+     * 
184
+     * @final
185
+     * 
186
+     * @return bool
187
+     */
188
+    public function isInvalid(): bool
189
+    {
190
+        return $this->statusCode < 100 || $this->statusCode >= 600;
191
+    }
192
+
193
+    /**
194
+     * Is response informative?
195
+     * 
196
+     * @final
197
+     * 
198
+     * @return bool
199
+     */
200
+    public function isInformational(): bool
201
+    {
202
+        return $this->statusCode >= 100 && $this->statusCode < 200;
203
+    }
204 204
 	
205
-	/**
206
-	 * Is the response a redirect?
207
-	 * 
208
-	 * @final
209
-	 * 
210
-	 * @return void
211
-	 */
212
-	public function isRedirection(): bool
213
-	{
214
-		return $this->statusCode >= 300 && $this->statusCode < 400;
215
-	}
205
+    /**
206
+     * Is the response a redirect?
207
+     * 
208
+     * @final
209
+     * 
210
+     * @return void
211
+     */
212
+    public function isRedirection(): bool
213
+    {
214
+        return $this->statusCode >= 300 && $this->statusCode < 400;
215
+    }
216 216
 	
217
-	/**
218
-	 * Is the response empty?
219
-	 * 
220
-	 * @final
221
-	 * 
222
-	 * @return bool
223
-	 */
224
-	public function isEmpty(): bool
225
-	{
226
-		return in_array($this->statusCode, [204, 304]);
227
-	}
217
+    /**
218
+     * Is the response empty?
219
+     * 
220
+     * @final
221
+     * 
222
+     * @return bool
223
+     */
224
+    public function isEmpty(): bool
225
+    {
226
+        return in_array($this->statusCode, [204, 304]);
227
+    }
228 228
 	
229
-	/**
230
-	 * Is the response a redirect of some form?
231
-	 * 
232
-	 * @return bool
233
-	 */
234
-	public function isRedirect(): bool
235
-	{
236
-		return in_array($this->statusCode, [301, 302, 303, 307, 308]);
237
-	}
229
+    /**
230
+     * Is the response a redirect of some form?
231
+     * 
232
+     * @return bool
233
+     */
234
+    public function isRedirect(): bool
235
+    {
236
+        return in_array($this->statusCode, [301, 302, 303, 307, 308]);
237
+    }
238 238
 }
239 239
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Http/RedirectResponse.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -127,13 +127,13 @@
 block discarded – undo
127 127
     }
128 128
 
129 129
     /**
130
-    * Redirects to another url. Sets the redirect header, sends the headers and exits.
131
-    * Can redirect via a Location header.
132
-    *
133
-    * @param  string  $url  The url
134
-    *
135
-    * @return static
136
-    */
130
+     * Redirects to another url. Sets the redirect header, sends the headers and exits.
131
+     * Can redirect via a Location header.
132
+     *
133
+     * @param  string  $url  The url
134
+     *
135
+     * @return static
136
+     */
137 137
     public function setTargetUrl($url): static
138 138
     {
139 139
         if ('' === ($url ?? '')) {
Please login to merge, or discard this patch.
src/components/Http/Resources/HttpRequest.php 2 patches
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -38,160 +38,160 @@  discard block
 block discarded – undo
38 38
  */
39 39
 trait HttpRequest
40 40
 {
41
-	/**
42
-	 * Get the http method parameter.
43
-	 * 
44
-	 * @var bool $httpMethodParameterOverride
45
-	 */
46
-	protected static $httpMethodParameterOverride = false;
47
-
48
-	/**
49
-	 * Holds the global active request instance.
50
-	 *
51
-	 * @var bool $requestURI
52
-	 */
53
-	protected static $requestURI;
54
-
55
-	/**
56
-	 * Get the custom parameters.
57
-	 * 
58
-	 * @var \Syscodes\Components\Http\Loaders\Parameters $attributes
59
-	 */
60
-	public $attributes;
61
-
62
-	/**
63
-	 * The base URL.
64
-	 * 
65
-	 * @var string $baseUrl
66
-	 */
67
-	protected $baseUrl;
68
-
69
-	/**
70
-	 * Get the client ip.
71
-	 * 
72
-	 * @var mixed $clientIp
73
-	 */
74
-	protected $clientIp;
75
-
76
-	/**
77
-	 * Gets cookies ($_COOKIE).
78
-	 * 
79
-	 * @var \Syscodes\Components\Http\Loaders\Inputs $cookies
80
-	 */
81
-	public $cookies;
82
-
83
-	/**
84
-	 * Gets the string with format JSON.
85
-	 * 
86
-	 * @var string|resource|object|null $content
87
-	 */
88
-	protected $content;
89
-
90
-	/**
91
-	 * The default Locale this request.
92
-	 * 
93
-	 * @var string $defaultLocale
94
-	 */
95
-	protected $defaultLocale = 'en';
41
+    /**
42
+     * Get the http method parameter.
43
+     * 
44
+     * @var bool $httpMethodParameterOverride
45
+     */
46
+    protected static $httpMethodParameterOverride = false;
47
+
48
+    /**
49
+     * Holds the global active request instance.
50
+     *
51
+     * @var bool $requestURI
52
+     */
53
+    protected static $requestURI;
54
+
55
+    /**
56
+     * Get the custom parameters.
57
+     * 
58
+     * @var \Syscodes\Components\Http\Loaders\Parameters $attributes
59
+     */
60
+    public $attributes;
61
+
62
+    /**
63
+     * The base URL.
64
+     * 
65
+     * @var string $baseUrl
66
+     */
67
+    protected $baseUrl;
68
+
69
+    /**
70
+     * Get the client ip.
71
+     * 
72
+     * @var mixed $clientIp
73
+     */
74
+    protected $clientIp;
75
+
76
+    /**
77
+     * Gets cookies ($_COOKIE).
78
+     * 
79
+     * @var \Syscodes\Components\Http\Loaders\Inputs $cookies
80
+     */
81
+    public $cookies;
82
+
83
+    /**
84
+     * Gets the string with format JSON.
85
+     * 
86
+     * @var string|resource|object|null $content
87
+     */
88
+    protected $content;
89
+
90
+    /**
91
+     * The default Locale this request.
92
+     * 
93
+     * @var string $defaultLocale
94
+     */
95
+    protected $defaultLocale = 'en';
96 96
 	
97
-	/**
98
-	 * Gets files request ($_FILES).
99
-	 * 
100
-	 * @var \Syscodes\Components\Http\Loaders\Files $files
101
-	 */
102
-	public $files;
97
+    /**
98
+     * Gets files request ($_FILES).
99
+     * 
100
+     * @var \Syscodes\Components\Http\Loaders\Files $files
101
+     */
102
+    public $files;
103 103
 	
104
-	/**
105
-	 * Get the headers request ($_SERVER).
106
-	 * 
107
-	 * @var \Syscodes\Components\Http\Loaders\Headers $headers
108
-	 */
109
-	public $headers;
110
-
111
-	/**
112
-	 * The current language of the application.
113
-	 * 
114
-	 * @var string $languages
115
-	 */
116
-	protected $languages;
104
+    /**
105
+     * Get the headers request ($_SERVER).
106
+     * 
107
+     * @var \Syscodes\Components\Http\Loaders\Headers $headers
108
+     */
109
+    public $headers;
110
+
111
+    /**
112
+     * The current language of the application.
113
+     * 
114
+     * @var string $languages
115
+     */
116
+    protected $languages;
117 117
 	
118
-	/**
119
-	 * Get the locale.
120
-	 * 
121
-	 * @var string $locale
122
-	 */
123
-	protected $locale;
118
+    /**
119
+     * Get the locale.
120
+     * 
121
+     * @var string $locale
122
+     */
123
+    protected $locale;
124 124
 	
125
-	/** 
126
-	 * The method name.
127
-	 * 
128
-	 * @var string $method
129
-	 */
130
-	protected $method;
131
-
132
-	/**
133
-	 * Query string parameters ($_GET).
134
-	 * 
135
-	 * @var \Syscodes\Components\Http\Loaders\Parameters $query
136
-	 */
137
-	public $query;
138
-
139
-	/**
140
-	 * Request body parameters ($_POST).
141
-	 * 
142
-	 * @var \Syscodes\Components\Http\Loaders\Parameters $request
143
-	 */
144
-	public $request;
145
-
146
-	/**
147
-	 * The detected uri and server variables ($_SERVER).
148
-	 * 
149
-	 * @var \Syscodes\Components\Http\Loaders\Server $server
150
-	 */
151
-	public $server;
152
-
153
-	/** 
154
-	 * List of routes uri.
155
-	 *
156
-	 * @var \Syscodes\Components\Http\URI $uri 
157
-	 */
158
-	public $uri;
159
-
160
-	/**
161
-	 * Stores the valid locale codes.
162
-	 * 
163
-	 * @var array $validLocales
164
-	 */
165
-	protected $validLocales = [];
166
-
167
-	/**
168
-	 * Constructor. Create new the Request class.
169
-	 * 
170
-	 * @param  array  $query
171
-	 * @param  array  $request
172
-	 * @param  array  $attributes
173
-	 * @param  array  $cookies
174
-	 * @param  array  $files
175
-	 * @param  array  $server
176
-	 * @param  string|resource|null $content  
177
-	 * 
178
-	 * @return void
179
-	 */
180
-	public function __construct(
181
-		array $query = [],
182
-		array $request = [],
183
-		array $attributes = [],
184
-		array $cookies = [],
185
-		array $files = [],
186
-		array $server = [],
187
-		$content = null
188
-	) {
189
-		$this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
125
+    /** 
126
+     * The method name.
127
+     * 
128
+     * @var string $method
129
+     */
130
+    protected $method;
131
+
132
+    /**
133
+     * Query string parameters ($_GET).
134
+     * 
135
+     * @var \Syscodes\Components\Http\Loaders\Parameters $query
136
+     */
137
+    public $query;
138
+
139
+    /**
140
+     * Request body parameters ($_POST).
141
+     * 
142
+     * @var \Syscodes\Components\Http\Loaders\Parameters $request
143
+     */
144
+    public $request;
145
+
146
+    /**
147
+     * The detected uri and server variables ($_SERVER).
148
+     * 
149
+     * @var \Syscodes\Components\Http\Loaders\Server $server
150
+     */
151
+    public $server;
152
+
153
+    /** 
154
+     * List of routes uri.
155
+     *
156
+     * @var \Syscodes\Components\Http\URI $uri 
157
+     */
158
+    public $uri;
159
+
160
+    /**
161
+     * Stores the valid locale codes.
162
+     * 
163
+     * @var array $validLocales
164
+     */
165
+    protected $validLocales = [];
166
+
167
+    /**
168
+     * Constructor. Create new the Request class.
169
+     * 
170
+     * @param  array  $query
171
+     * @param  array  $request
172
+     * @param  array  $attributes
173
+     * @param  array  $cookies
174
+     * @param  array  $files
175
+     * @param  array  $server
176
+     * @param  string|resource|null $content  
177
+     * 
178
+     * @return void
179
+     */
180
+    public function __construct(
181
+        array $query = [],
182
+        array $request = [],
183
+        array $attributes = [],
184
+        array $cookies = [],
185
+        array $files = [],
186
+        array $server = [],
187
+        $content = null
188
+    ) {
189
+        $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
190 190
 		
191
-		$this->detectLocale();
192
-	}
191
+        $this->detectLocale();
192
+    }
193 193
 
194
-	/**
194
+    /**
195 195
      * Enables support for the _method request parameter to determine the intended HTTP method.
196 196
      * 
197 197
      * @return void
@@ -201,361 +201,361 @@  discard block
 block discarded – undo
201 201
         self::$httpMethodParameterOverride = true;
202 202
     }
203 203
 	
204
-	/**
205
-	 * Checks whether support for the _method request parameter is enabled.
206
-	 * 
207
-	 * @return bool
208
-	 */
209
-	public static function getHttpMethodParameterOverride(): bool
210
-	{
211
-		return self::$httpMethodParameterOverride;
212
-	}
213
-
214
-	/**
215
-	 * Creates an Syscodes request from of the Request class instance.
216
-	 * 
217
-	 * @param  \Syscodes\Components\Http\Request  $request
218
-	 * 
219
-	 * @return static
220
-	 */
221
-	public static function createFromRequest($request): static
222
-	{
223
-		$newRequest = (new static)->duplicate(
224
-			$request->query->all(), $request->request->all(), $request->attributes->all(),
225
-			$request->cookies->all(), $request->files->all(), $request->server->all()
226
-		);
204
+    /**
205
+     * Checks whether support for the _method request parameter is enabled.
206
+     * 
207
+     * @return bool
208
+     */
209
+    public static function getHttpMethodParameterOverride(): bool
210
+    {
211
+        return self::$httpMethodParameterOverride;
212
+    }
213
+
214
+    /**
215
+     * Creates an Syscodes request from of the Request class instance.
216
+     * 
217
+     * @param  \Syscodes\Components\Http\Request  $request
218
+     * 
219
+     * @return static
220
+     */
221
+    public static function createFromRequest($request): static
222
+    {
223
+        $newRequest = (new static)->duplicate(
224
+            $request->query->all(), $request->request->all(), $request->attributes->all(),
225
+            $request->cookies->all(), $request->files->all(), $request->server->all()
226
+        );
227 227
 		
228
-		$newRequest->headers->replace($request->headers->all());
228
+        $newRequest->headers->replace($request->headers->all());
229 229
 		
230
-		$newRequest->content = $request->content;
230
+        $newRequest->content = $request->content;
231 231
 		
232
-		if ($newRequest->isJson()) {
233
-			$newRequest->request = $newRequest->json();
234
-		}
232
+        if ($newRequest->isJson()) {
233
+            $newRequest->request = $newRequest->json();
234
+        }
235 235
 		
236
-		return $newRequest;
237
-	}
238
-
239
-	/**
240
-	 * Creates a new request with value from PHP's super global.
241
-	 * 
242
-	 * @return static
243
-	 */
244
-	public static function createFromRequestGlobals(): static
245
-	{
246
-		$request = static::createFromRequestFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
247
-
248
-		if (Str::startsWith($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
249
-		    && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])) {
250
-			parse_str($request->getContent(), $data);
251
-			$request->request = new Inputs($data);
252
-		}
253
-
254
-		return $request;
255
-	}
256
-
257
-	/**
258
-	 * Creates a new request from a factory.
259
-	 * 
260
-	 * @param  array  $query
261
-	 * @param  array  $request
262
-	 * @param  array  $attributes
263
-	 * @param  array  $cookies
264
-	 * @param  array  $files
265
-	 * @param  array  $server
266
-	 * 
267
-	 * @return static
268
-	 */
269
-	private static function createFromRequestFactory(
270
-		array $query = [], 
271
-		array $request = [],
272
-		array $attributes = [] ,
273
-		array $cookies = [], 
274
-		array $files = [], 
275
-		array $server = []
276
-	): static {
277
-		if (self::$requestURI) {
278
-			$request = (self::$requestURI)($query, $request, [], $cookies, $files, $server);
279
-
280
-			if ( ! $request instanceof self) {
281
-				throw new LogicException('The Request active must return an instance of Syscodes\Components\Http\Request');
282
-			}
283
-
284
-			return $request;
285
-		}
286
-
287
-		return new static($query, $request, $attributes, $cookies, $files, $server);
288
-	}
289
-
290
-	/**
291
-	 * Returns the factory request currently being used.
292
-	 *
293
-	 * @param  \Syscodes\Components\Http\Request|callable|null  $request  
294
-	 *
295
-	 * @return void
296
-	 */
297
-	public static function setFactory(?callable $request): void
298
-	{
299
-		self::$requestURI = $request;
300
-	}
301
-
302
-	/**
303
-	 * Sets the parameters for this request.
304
-	 * 
305
-	 * @param  array  $query
306
-	 * @param  array  $request
307
-	 * @param  array  $attributes
308
-	 * @param  array  $cookies
309
-	 * @param  array  $files
310
-	 * @param  array  $server
311
-	 * 
312
-	 * @return void
313
-	 */
314
-	public function initialize(
315
-		array $query = [], 
316
-		array $request = [],
317
-		array $attributes = [],
318
-		array $cookies = [], 
319
-		array $files = [], 
320
-		array $server = [], 
321
-		$content = null
322
-	): void {
323
-		$this->query = new Inputs($query);
324
-		$this->request = new Inputs($request);
325
-		$this->attributes = new Parameters($attributes);
326
-		$this->cookies = new Inputs($cookies);
327
-		$this->files = new Files($files);
328
-		$this->server = new Server($server);
329
-		$this->headers = new Headers($this->server->all());
330
-
331
-		// Variables initialized
332
-		$this->uri = new URI;
333
-		$this->method = null;
334
-		$this->baseUrl = null;
335
-		$this->content = $content;
336
-		$this->pathInfo = null;
337
-		$this->languages = null;
338
-		$this->acceptableContentTypes = null;
339
-		$this->validLocales = config('app.supportedLocales');
340
-		$this->clientIp = new RequestClientIP($this->server->all());
341
-	}
342
-
343
-	/**
344
-	 * Clones a request and overrides some of its parameters.
345
-	 * 
346
-	 * @param  array|null  $query
347
-	 * @param  array|null  $request
348
-	 * @param  array|null  $attributes
349
-	 * @param  array|null  $cookies
350
-	 * @param  array|null  $files
351
-	 * @param  array|null  $server
352
-	 * 
353
-	 * @return static
354
-	 */
355
-	public function duplicate(
356
-		array $query = null, 
357
-		array $request = null,
358
-		array $attributes = null,
359
-		array $cookies = null,
360
-		array $files = null,
361
-		array $server = null
362
-	): static {
363
-		$duplicate = clone $this;
364
-
365
-		if (null !== $query) {
366
-			$duplicate->query = new Inputs($query);
367
-		}
368
-
369
-		if (null !== $request) {
370
-			$duplicate->request = new Inputs($request);
371
-		}
372
-
373
-		if (null !== $attributes) {
374
-			$duplicate->attributes = new Parameters($attributes);
375
-		}
376
-
377
-		if (null !== $cookies) {
378
-			$duplicate->cookies = new Inputs($cookies);
379
-		}
380
-
381
-		if (null !== $files) {
382
-			$duplicate->files = new Files($files);
383
-		}
384
-
385
-		if (null !== $server) {
386
-			$duplicate->server  = new Server($server);
387
-			$duplicate->headers = new Headers($duplicate->server->all());
388
-		}
389
-
390
-		$duplicate->uri = new URI;
391
-		$duplicate->locale = null;
392
-		$duplicate->method = null;
393
-		$duplicate->baseUrl = null;
394
-		$duplicate->pathInfo = null;
395
-		$duplicate->validLocales = config('app.supportedLocales');
396
-		$duplicate->clientIp = new RequestClientIP($duplicate->server->all());
397
-
398
-		return $duplicate;		
399
-	}
400
-
401
-	/**
402
-	 * Handles setting up the locale, auto-detecting of language.
403
-	 * 
404
-	 * @return void
405
-	 */
406
-	public function detectLocale(): void
407
-	{
408
-		$this->languages = $this->defaultLocale = config('app.locale');
409
-
410
-		$this->setLocale($this->validLocales[0]);
411
-	}
412
-
413
-	/**
414
-	 * Returns the default locale as set.
415
-	 * 
416
-	 * @return string
417
-	 */
418
-	public function getDefaultLocale(): string
419
-	{
420
-		return $this->defaultLocale;
421
-	}
422
-
423
-	/**
424
-	 * Gets the current locale, with a fallback to the default.
425
-	 * 
426
-	 * @return string 
427
-	 */
428
-	public function getLocale(): string
429
-	{
430
-		return $this->languages ?: $this->defaultLocale;
431
-	}
432
-
433
-	/**
434
-	 * Sets the locale string for this request.
435
-	 * 
436
-	 * @param  string  $locale
437
-	 * 
438
-	 * @return static
439
-	 */
440
-	public function setLocale(string $locale): static
441
-	{
442
-		if ( ! in_array($locale, $this->validLocales, true)) {
443
-			$locale = $this->defaultLocale;
444
-		}
236
+        return $newRequest;
237
+    }
238
+
239
+    /**
240
+     * Creates a new request with value from PHP's super global.
241
+     * 
242
+     * @return static
243
+     */
244
+    public static function createFromRequestGlobals(): static
245
+    {
246
+        $request = static::createFromRequestFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
247
+
248
+        if (Str::startsWith($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
249
+            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])) {
250
+            parse_str($request->getContent(), $data);
251
+            $request->request = new Inputs($data);
252
+        }
253
+
254
+        return $request;
255
+    }
256
+
257
+    /**
258
+     * Creates a new request from a factory.
259
+     * 
260
+     * @param  array  $query
261
+     * @param  array  $request
262
+     * @param  array  $attributes
263
+     * @param  array  $cookies
264
+     * @param  array  $files
265
+     * @param  array  $server
266
+     * 
267
+     * @return static
268
+     */
269
+    private static function createFromRequestFactory(
270
+        array $query = [], 
271
+        array $request = [],
272
+        array $attributes = [] ,
273
+        array $cookies = [], 
274
+        array $files = [], 
275
+        array $server = []
276
+    ): static {
277
+        if (self::$requestURI) {
278
+            $request = (self::$requestURI)($query, $request, [], $cookies, $files, $server);
279
+
280
+            if ( ! $request instanceof self) {
281
+                throw new LogicException('The Request active must return an instance of Syscodes\Components\Http\Request');
282
+            }
283
+
284
+            return $request;
285
+        }
286
+
287
+        return new static($query, $request, $attributes, $cookies, $files, $server);
288
+    }
289
+
290
+    /**
291
+     * Returns the factory request currently being used.
292
+     *
293
+     * @param  \Syscodes\Components\Http\Request|callable|null  $request  
294
+     *
295
+     * @return void
296
+     */
297
+    public static function setFactory(?callable $request): void
298
+    {
299
+        self::$requestURI = $request;
300
+    }
301
+
302
+    /**
303
+     * Sets the parameters for this request.
304
+     * 
305
+     * @param  array  $query
306
+     * @param  array  $request
307
+     * @param  array  $attributes
308
+     * @param  array  $cookies
309
+     * @param  array  $files
310
+     * @param  array  $server
311
+     * 
312
+     * @return void
313
+     */
314
+    public function initialize(
315
+        array $query = [], 
316
+        array $request = [],
317
+        array $attributes = [],
318
+        array $cookies = [], 
319
+        array $files = [], 
320
+        array $server = [], 
321
+        $content = null
322
+    ): void {
323
+        $this->query = new Inputs($query);
324
+        $this->request = new Inputs($request);
325
+        $this->attributes = new Parameters($attributes);
326
+        $this->cookies = new Inputs($cookies);
327
+        $this->files = new Files($files);
328
+        $this->server = new Server($server);
329
+        $this->headers = new Headers($this->server->all());
330
+
331
+        // Variables initialized
332
+        $this->uri = new URI;
333
+        $this->method = null;
334
+        $this->baseUrl = null;
335
+        $this->content = $content;
336
+        $this->pathInfo = null;
337
+        $this->languages = null;
338
+        $this->acceptableContentTypes = null;
339
+        $this->validLocales = config('app.supportedLocales');
340
+        $this->clientIp = new RequestClientIP($this->server->all());
341
+    }
342
+
343
+    /**
344
+     * Clones a request and overrides some of its parameters.
345
+     * 
346
+     * @param  array|null  $query
347
+     * @param  array|null  $request
348
+     * @param  array|null  $attributes
349
+     * @param  array|null  $cookies
350
+     * @param  array|null  $files
351
+     * @param  array|null  $server
352
+     * 
353
+     * @return static
354
+     */
355
+    public function duplicate(
356
+        array $query = null, 
357
+        array $request = null,
358
+        array $attributes = null,
359
+        array $cookies = null,
360
+        array $files = null,
361
+        array $server = null
362
+    ): static {
363
+        $duplicate = clone $this;
364
+
365
+        if (null !== $query) {
366
+            $duplicate->query = new Inputs($query);
367
+        }
368
+
369
+        if (null !== $request) {
370
+            $duplicate->request = new Inputs($request);
371
+        }
372
+
373
+        if (null !== $attributes) {
374
+            $duplicate->attributes = new Parameters($attributes);
375
+        }
376
+
377
+        if (null !== $cookies) {
378
+            $duplicate->cookies = new Inputs($cookies);
379
+        }
380
+
381
+        if (null !== $files) {
382
+            $duplicate->files = new Files($files);
383
+        }
384
+
385
+        if (null !== $server) {
386
+            $duplicate->server  = new Server($server);
387
+            $duplicate->headers = new Headers($duplicate->server->all());
388
+        }
389
+
390
+        $duplicate->uri = new URI;
391
+        $duplicate->locale = null;
392
+        $duplicate->method = null;
393
+        $duplicate->baseUrl = null;
394
+        $duplicate->pathInfo = null;
395
+        $duplicate->validLocales = config('app.supportedLocales');
396
+        $duplicate->clientIp = new RequestClientIP($duplicate->server->all());
397
+
398
+        return $duplicate;		
399
+    }
400
+
401
+    /**
402
+     * Handles setting up the locale, auto-detecting of language.
403
+     * 
404
+     * @return void
405
+     */
406
+    public function detectLocale(): void
407
+    {
408
+        $this->languages = $this->defaultLocale = config('app.locale');
409
+
410
+        $this->setLocale($this->validLocales[0]);
411
+    }
412
+
413
+    /**
414
+     * Returns the default locale as set.
415
+     * 
416
+     * @return string
417
+     */
418
+    public function getDefaultLocale(): string
419
+    {
420
+        return $this->defaultLocale;
421
+    }
422
+
423
+    /**
424
+     * Gets the current locale, with a fallback to the default.
425
+     * 
426
+     * @return string 
427
+     */
428
+    public function getLocale(): string
429
+    {
430
+        return $this->languages ?: $this->defaultLocale;
431
+    }
432
+
433
+    /**
434
+     * Sets the locale string for this request.
435
+     * 
436
+     * @param  string  $locale
437
+     * 
438
+     * @return static
439
+     */
440
+    public function setLocale(string $locale): static
441
+    {
442
+        if ( ! in_array($locale, $this->validLocales, true)) {
443
+            $locale = $this->defaultLocale;
444
+        }
445 445
 		
446
-		$this->languages = $locale;
446
+        $this->languages = $locale;
447 447
 
448
-		Locale::setDefault($locale);
448
+        Locale::setDefault($locale);
449 449
 			
450
-		return $this;
451
-	}
452
-
453
-	/**
454
-	 * Returns the host name.
455
-	 * 
456
-	 * @return string
457
-	 */
458
-	public function getHost(): string
459
-	{
460
-		if ($forwardedHost = $this->server->get('HTTP_X_FORWARDED_HOST')) {
461
-			$host = $forwardedHost[0];
462
-		} elseif ( ! $host = $this->headers->get('HOST')) {
463
-			if ( ! $host = $this->server->get('SERVER_NAME')) {
464
-				$host = $this->server->get('REMOTE_ADDR', '');
465
-			}
466
-		}
467
-
468
-		$host = strtolower(preg_replace('/:\d+$/', '', trim(($host))));
450
+        return $this;
451
+    }
452
+
453
+    /**
454
+     * Returns the host name.
455
+     * 
456
+     * @return string
457
+     */
458
+    public function getHost(): string
459
+    {
460
+        if ($forwardedHost = $this->server->get('HTTP_X_FORWARDED_HOST')) {
461
+            $host = $forwardedHost[0];
462
+        } elseif ( ! $host = $this->headers->get('HOST')) {
463
+            if ( ! $host = $this->server->get('SERVER_NAME')) {
464
+                $host = $this->server->get('REMOTE_ADDR', '');
465
+            }
466
+        }
467
+
468
+        $host = strtolower(preg_replace('/:\d+$/', '', trim(($host))));
469 469
 		
470
-		return $this->uri->setHost($host);
471
-	}
472
-
473
-	/**
474
-	 * Returns the port on which the request is made.
475
-	 * 
476
-	 * @return int
477
-	 */
478
-	public function getPort(): int
479
-	{
480
-		if ( ! $this->server->get('HTTP_HOST')) {
481
-			return $this->server->get('SERVER_PORT');
482
-		}
470
+        return $this->uri->setHost($host);
471
+    }
472
+
473
+    /**
474
+     * Returns the port on which the request is made.
475
+     * 
476
+     * @return int
477
+     */
478
+    public function getPort(): int
479
+    {
480
+        if ( ! $this->server->get('HTTP_HOST')) {
481
+            return $this->server->get('SERVER_PORT');
482
+        }
483 483
 		
484
-		return 'https' === $this->getScheme() ? $this->uri->setPort(443) : $this->uri->setPort(80);
485
-	}
486
-
487
-	/**
488
-	 * Gets the request's scheme.
489
-	 * 
490
-	 * @return string
491
-	 */
492
-	public function getScheme(): string
493
-	{
494
-		return $this->secure() ? $this->uri->setScheme('https') : $this->uri->setScheme('http');
495
-	}
496
-
497
-	/**
498
-	 * Get the user.
499
-	 * 
500
-	 * @return string|null
501
-	 */
502
-	public function getUser(): ?string
503
-	{
504
-		$user = $this->uri->setUser(
505
-			$this->headers->get('PHP_AUTH_USER')
506
-		);
507
-
508
-		return $user;
509
-	}
510
-
511
-	/**
512
-	 * Get the password.
513
-	 * 
514
-	 * @return string|null
515
-	 */
516
-	public function getPassword(): ?string
517
-	{
518
-		$password = $this->uri->setPassword(
519
-			$this->headers->get('PHP_AUTH_PW')
520
-		);
521
-
522
-		return $password;
523
-	}
524
-
525
-	/**
526
-	 * Gets the user info.
527
-	 * 
528
-	 * @return string|null
529
-	 */
530
-	public function getUserInfo(): ?string
531
-	{
532
-		return $this->uri->getUserInfo();
533
-	}
534
-
535
-	/**
536
-	 * Returns the HTTP host being requested.
537
-	 * 
538
-	 * @return string
539
-	 */
540
-	public function getHttpHost(): string
541
-	{
542
-		$scheme = $this->getScheme();
543
-		$port   = $this->getPort();
544
-
545
-		if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port))	{
546
-			return $this->getHost();
547
-		}
548
-
549
-		return $this->getHost().':'.$port;
550
-	}
551
-
552
-	/**
553
-	 * Gets the scheme and HTTP host.
554
-	 * 
555
-	 * @return string
556
-	 */
557
-	public function getSchemeWithHttpHost(): string
558
-	{
559
-		return $this->getScheme().'://'.$this->getHttpHost();
560
-	}
484
+        return 'https' === $this->getScheme() ? $this->uri->setPort(443) : $this->uri->setPort(80);
485
+    }
486
+
487
+    /**
488
+     * Gets the request's scheme.
489
+     * 
490
+     * @return string
491
+     */
492
+    public function getScheme(): string
493
+    {
494
+        return $this->secure() ? $this->uri->setScheme('https') : $this->uri->setScheme('http');
495
+    }
496
+
497
+    /**
498
+     * Get the user.
499
+     * 
500
+     * @return string|null
501
+     */
502
+    public function getUser(): ?string
503
+    {
504
+        $user = $this->uri->setUser(
505
+            $this->headers->get('PHP_AUTH_USER')
506
+        );
507
+
508
+        return $user;
509
+    }
510
+
511
+    /**
512
+     * Get the password.
513
+     * 
514
+     * @return string|null
515
+     */
516
+    public function getPassword(): ?string
517
+    {
518
+        $password = $this->uri->setPassword(
519
+            $this->headers->get('PHP_AUTH_PW')
520
+        );
521
+
522
+        return $password;
523
+    }
524
+
525
+    /**
526
+     * Gets the user info.
527
+     * 
528
+     * @return string|null
529
+     */
530
+    public function getUserInfo(): ?string
531
+    {
532
+        return $this->uri->getUserInfo();
533
+    }
534
+
535
+    /**
536
+     * Returns the HTTP host being requested.
537
+     * 
538
+     * @return string
539
+     */
540
+    public function getHttpHost(): string
541
+    {
542
+        $scheme = $this->getScheme();
543
+        $port   = $this->getPort();
544
+
545
+        if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port))	{
546
+            return $this->getHost();
547
+        }
548
+
549
+        return $this->getHost().':'.$port;
550
+    }
551
+
552
+    /**
553
+     * Gets the scheme and HTTP host.
554
+     * 
555
+     * @return string
556
+     */
557
+    public function getSchemeWithHttpHost(): string
558
+    {
559
+        return $this->getScheme().'://'.$this->getHttpHost();
560
+    }
561 561
 }
562 562
\ 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
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	private static function createFromRequestFactory(
270 270
 		array $query = [], 
271 271
 		array $request = [],
272
-		array $attributes = [] ,
272
+		array $attributes = [],
273 273
 		array $cookies = [], 
274 274
 		array $files = [], 
275 275
 		array $server = []
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 		$scheme = $this->getScheme();
543 543
 		$port   = $this->getPort();
544 544
 
545
-		if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port))	{
545
+		if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port)) {
546 546
 			return $this->getHost();
547 547
 		}
548 548
 
Please login to merge, or discard this patch.
src/components/Http/Request.php 2 patches
Indentation   +657 added lines, -657 removed lines patch added patch discarded remove patch
@@ -43,283 +43,283 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class Request
45 45
 {
46
-	use HttpRequest,
47
-	    HttpResources,
48
-	    CanBePrecognitive,	    
49
-	    InteractsWithInput,
50
-	    InteractsWithFlashData,
51
-	    InteractsWithContentTypes;
52
-
53
-	/**
54
-	 * Get the acceptable of content types.
55
-	 * 
56
-	 * @var string[] $acceptableContenTypes
57
-	 */
58
-	protected $acceptableContentTypes;
59
-
60
-	/**
61
-	 * The decoded JSON content for the request.
62
-	 * 
63
-	 * @var \Syscodes\Components\Http\Loaders\Parameters|null $json
64
-	 */
65
-	protected $json;
66
-
67
-	/**
68
-	 * The path info of URL.
69
-	 * 
70
-	 * @var string $pathInfo
71
-	 */
72
-	protected $pathInfo;
73
-
74
-	/**
75
-	 * Get request URI.
76
-	 * 
77
-	 * @var string $requestToUri
78
-	 */
79
-	protected $requestToUri;
80
-
81
-	/**
82
-	 * Get the route resolver callback.
83
-	 * 
84
-	 * @var \Closure $routeResolver
85
-	 */
86
-	protected $routeResolver;
87
-
88
-	/**
89
-	 * The Session implementation.
90
-	 * 
91
-	 * @var \Syscodes\Components\Contracts\Session\Session $session
92
-	 */
93
-	protected $session;
94
-
95
-	/**
96
-	 * Create a new Syscodes HTTP request from server variables.
97
-	 * 
98
-	 * @return static
99
-	 */
100
-	public static function capture(): static
101
-	{
102
-		static::enabledHttpMethodParameterOverride();
46
+    use HttpRequest,
47
+        HttpResources,
48
+        CanBePrecognitive,	    
49
+        InteractsWithInput,
50
+        InteractsWithFlashData,
51
+        InteractsWithContentTypes;
52
+
53
+    /**
54
+     * Get the acceptable of content types.
55
+     * 
56
+     * @var string[] $acceptableContenTypes
57
+     */
58
+    protected $acceptableContentTypes;
59
+
60
+    /**
61
+     * The decoded JSON content for the request.
62
+     * 
63
+     * @var \Syscodes\Components\Http\Loaders\Parameters|null $json
64
+     */
65
+    protected $json;
66
+
67
+    /**
68
+     * The path info of URL.
69
+     * 
70
+     * @var string $pathInfo
71
+     */
72
+    protected $pathInfo;
73
+
74
+    /**
75
+     * Get request URI.
76
+     * 
77
+     * @var string $requestToUri
78
+     */
79
+    protected $requestToUri;
80
+
81
+    /**
82
+     * Get the route resolver callback.
83
+     * 
84
+     * @var \Closure $routeResolver
85
+     */
86
+    protected $routeResolver;
87
+
88
+    /**
89
+     * The Session implementation.
90
+     * 
91
+     * @var \Syscodes\Components\Contracts\Session\Session $session
92
+     */
93
+    protected $session;
94
+
95
+    /**
96
+     * Create a new Syscodes HTTP request from server variables.
97
+     * 
98
+     * @return static
99
+     */
100
+    public static function capture(): static
101
+    {
102
+        static::enabledHttpMethodParameterOverride();
103 103
 		
104
-		return static::createFromRequest(static::createFromRequestGlobals());
105
-	}
106
-
107
-	/**
108
-	 * Returns the desired segment, or $default if it does not exist.
109
-	 *
110
-	 * @param  int  $index  The segment number (1-based index)
111
-	 * @param  mixed  $default  Default value to return
112
-	 *
113
-	 * @return string
114
-	 */
115
-	public function segment($index, $default = null)
116
-	{
117
-		return $this->uri->getSegment($index, $default);
118
-	}
119
-
120
-	/**
121
-	 * Returns all segments in an array. For total of segments
122
-	 * used the function PHP count().
123
-	 *
124
-	 * @return array|null
125
-	 */
126
-	public function segments()
127
-	{
128
-		return $this->uri->getSegments();
129
-	}
130
-
131
-	/**
132
-	 * Returns the total number of segment.
133
-	 *
134
-	 * @return int|null  
135
-	 */
136
-	public function totalSegments()
137
-	{
138
-		return $this->uri->getTotalSegments();
139
-	}
140
-
141
-	/**
142
-	 * Returns the full request string.
143
-	 * 
144
-	 * @param  string  $key
145
-	 * @param  mixed  $default
146
-	 *
147
-	 * @return mixed 
148
-	 */
149
-	public function get(string $key, $default = null) 
150
-	{
151
-		if ($this !== $result = $this->attributes->get($key, $this)) {
152
-			return $result;
153
-		}
154
-
155
-		if ($this->query->has($key)) {
156
-			return $this->query->all()[$key];
157
-		}
104
+        return static::createFromRequest(static::createFromRequestGlobals());
105
+    }
106
+
107
+    /**
108
+     * Returns the desired segment, or $default if it does not exist.
109
+     *
110
+     * @param  int  $index  The segment number (1-based index)
111
+     * @param  mixed  $default  Default value to return
112
+     *
113
+     * @return string
114
+     */
115
+    public function segment($index, $default = null)
116
+    {
117
+        return $this->uri->getSegment($index, $default);
118
+    }
119
+
120
+    /**
121
+     * Returns all segments in an array. For total of segments
122
+     * used the function PHP count().
123
+     *
124
+     * @return array|null
125
+     */
126
+    public function segments()
127
+    {
128
+        return $this->uri->getSegments();
129
+    }
130
+
131
+    /**
132
+     * Returns the total number of segment.
133
+     *
134
+     * @return int|null  
135
+     */
136
+    public function totalSegments()
137
+    {
138
+        return $this->uri->getTotalSegments();
139
+    }
140
+
141
+    /**
142
+     * Returns the full request string.
143
+     * 
144
+     * @param  string  $key
145
+     * @param  mixed  $default
146
+     *
147
+     * @return mixed 
148
+     */
149
+    public function get(string $key, $default = null) 
150
+    {
151
+        if ($this !== $result = $this->attributes->get($key, $this)) {
152
+            return $result;
153
+        }
154
+
155
+        if ($this->query->has($key)) {
156
+            return $this->query->all()[$key];
157
+        }
158 158
 		
159
-		if ($this->request->has($key)) {
160
-			return $this->request->all()[$key];
161
-		}
159
+        if ($this->request->has($key)) {
160
+            return $this->request->all()[$key];
161
+        }
162 162
 		
163
-		return $default;
164
-	}
165
-
166
-	/**
167
-	 * Gets the Session.
168
-	 * 
169
-	 * @return \Syscodes\Components\Http\Session\SessionInterface
170
-	 * 
171
-	 * @throws \Syscodes\Components\Http\Exceptions\SessionNotFoundException
172
-	 */
173
-	public function getSession()
174
-	{
175
-		$this->hasSession()
176
-		            ? new SessionDecorator($this->session())
177
-					: throw new SessionNotFoundException;
178
-	}
179
-
180
-	/**
181
-	 * Whether the request contains a Session object.
182
-	 * 
183
-	 * @return bool
184
-	 */
185
-	public function hasSession(): bool
186
-	{
187
-		return ! is_null($this->session);
188
-	}
189
-
190
-	/**
191
-	 * Get the session associated with the request.
192
-	 * 
193
-	 * @return \Syscodes\Components\Contracts\Session\Session
194
-	 * 
195
-	 * @throws RuntimeException
196
-	 */
197
-	public function session()
198
-	{
199
-		if ( ! $this->hasSession()) {
200
-			throw new RuntimeException('Session store not set on request');
201
-		}
163
+        return $default;
164
+    }
165
+
166
+    /**
167
+     * Gets the Session.
168
+     * 
169
+     * @return \Syscodes\Components\Http\Session\SessionInterface
170
+     * 
171
+     * @throws \Syscodes\Components\Http\Exceptions\SessionNotFoundException
172
+     */
173
+    public function getSession()
174
+    {
175
+        $this->hasSession()
176
+                    ? new SessionDecorator($this->session())
177
+                    : throw new SessionNotFoundException;
178
+    }
179
+
180
+    /**
181
+     * Whether the request contains a Session object.
182
+     * 
183
+     * @return bool
184
+     */
185
+    public function hasSession(): bool
186
+    {
187
+        return ! is_null($this->session);
188
+    }
189
+
190
+    /**
191
+     * Get the session associated with the request.
192
+     * 
193
+     * @return \Syscodes\Components\Contracts\Session\Session
194
+     * 
195
+     * @throws RuntimeException
196
+     */
197
+    public function session()
198
+    {
199
+        if ( ! $this->hasSession()) {
200
+            throw new RuntimeException('Session store not set on request');
201
+        }
202 202
 		
203
-		return $this->session;
204
-	}
203
+        return $this->session;
204
+    }
205 205
 	
206
-	/**
207
-	 * Set the session instance on the request.
208
-	 * 
209
-	 * @param  \Syscodes\Components\Contracts\Session\Session  $session
210
-	 * 
211
-	 * @return void
212
-	 */
213
-	public function setSession($session): void
214
-	{
215
-		$this->session = $session;
216
-	}
217
-
218
-	/**
219
-	 * Get the JSON payload for the request.
220
-	 * 
221
-	 * @param  string|null  $key  
222
-	 * @param  mixed  $default  
223
-	 * 
224
-	 * @return \Syscodes\Components\Http\Loaders\Parameters|mixed
225
-	 */
226
-	public function json($key = null, $default = null)
227
-	{
228
-		if ( ! isset($this->json)) {
229
-			$this->json = new Parameters((array) json_decode($this->getContent(), true));
230
-		}
231
-
232
-		if (is_null($key)) {
233
-			return $this->json;
234
-		}
235
-
236
-		return Arr::get($this->json->all(), $key, $default);
237
-	}
238
-
239
-	/**
240
-	 * Set the JSON payload for the request.
241
-	 * 
242
-	 * @param  \Syscodes\Components\Http\Loaders\Parameters  $json
243
-	 * 
244
-	 * @return static
245
-	 */
246
-	public function setJson($json): static
247
-	{
248
-		$this->json = $json;
249
-
250
-		return $this;
251
-	}
206
+    /**
207
+     * Set the session instance on the request.
208
+     * 
209
+     * @param  \Syscodes\Components\Contracts\Session\Session  $session
210
+     * 
211
+     * @return void
212
+     */
213
+    public function setSession($session): void
214
+    {
215
+        $this->session = $session;
216
+    }
217
+
218
+    /**
219
+     * Get the JSON payload for the request.
220
+     * 
221
+     * @param  string|null  $key  
222
+     * @param  mixed  $default  
223
+     * 
224
+     * @return \Syscodes\Components\Http\Loaders\Parameters|mixed
225
+     */
226
+    public function json($key = null, $default = null)
227
+    {
228
+        if ( ! isset($this->json)) {
229
+            $this->json = new Parameters((array) json_decode($this->getContent(), true));
230
+        }
231
+
232
+        if (is_null($key)) {
233
+            return $this->json;
234
+        }
235
+
236
+        return Arr::get($this->json->all(), $key, $default);
237
+    }
238
+
239
+    /**
240
+     * Set the JSON payload for the request.
241
+     * 
242
+     * @param  \Syscodes\Components\Http\Loaders\Parameters  $json
243
+     * 
244
+     * @return static
245
+     */
246
+    public function setJson($json): static
247
+    {
248
+        $this->json = $json;
249
+
250
+        return $this;
251
+    }
252 252
 	
253
-	/**
254
-	 * Gets a list of content types acceptable by the client browser in preferable order.
255
-	 * 
256
-	 * @return string[]
257
-	 */
258
-	public function getAcceptableContentTypes(): array
259
-	{
260
-		if (null !== $this->acceptableContentTypes) {
261
-			return $this->acceptableContentTypes;
262
-		}
253
+    /**
254
+     * Gets a list of content types acceptable by the client browser in preferable order.
255
+     * 
256
+     * @return string[]
257
+     */
258
+    public function getAcceptableContentTypes(): array
259
+    {
260
+        if (null !== $this->acceptableContentTypes) {
261
+            return $this->acceptableContentTypes;
262
+        }
263 263
 		
264
-		return $this->acceptableContentTypes = array_map('strval', [$this->headers->get('Accept')]);
265
-	}
266
-
267
-	/**
268
-	 * Returns whether this is an AJAX request or not.
269
-	 * Alias of isXmlHttpRequest().
270
-	 *
271
-	 * @return bool
272
-	 */
273
-	public function ajax(): bool
274
-	{
275
-		return $this->isXmlHttpRequest();
276
-	}
277
-
278
-	/**
279
-	 * Returns whether this is an AJAX request or not.
280
-	 *
281
-	 * @return bool
282
-	 */
283
-	public function isXmlHttpRequest(): bool
284
-	{
285
-		return ! empty($this->server->get('HTTP_X_REQUESTED_WITH')) && 
286
-				strtolower($this->server->get('HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest';
287
-	}
264
+        return $this->acceptableContentTypes = array_map('strval', [$this->headers->get('Accept')]);
265
+    }
266
+
267
+    /**
268
+     * Returns whether this is an AJAX request or not.
269
+     * Alias of isXmlHttpRequest().
270
+     *
271
+     * @return bool
272
+     */
273
+    public function ajax(): bool
274
+    {
275
+        return $this->isXmlHttpRequest();
276
+    }
277
+
278
+    /**
279
+     * Returns whether this is an AJAX request or not.
280
+     *
281
+     * @return bool
282
+     */
283
+    public function isXmlHttpRequest(): bool
284
+    {
285
+        return ! empty($this->server->get('HTTP_X_REQUESTED_WITH')) && 
286
+                strtolower($this->server->get('HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest';
287
+    }
288 288
 	
289
-	/**
290
-	 * Determine if the request is the result of a PJAX call.
291
-	 * 
292
-	 * @return bool
293
-	 */
294
-	public function pjax(): bool
295
-	{
296
-		return $this->headers->get('X-PJAX') == true;
297
-	}
289
+    /**
290
+     * Determine if the request is the result of a PJAX call.
291
+     * 
292
+     * @return bool
293
+     */
294
+    public function pjax(): bool
295
+    {
296
+        return $this->headers->get('X-PJAX') == true;
297
+    }
298 298
 	
299
-	/**
300
-	 * Determine if the request is the result of a prefetch call.
301
-	 * 
302
-	 * @return bool
303
-	 */
304
-	public function prefetch(): bool
305
-	{
306
-		return strcasecmp($this->server->get('HTTP_X_MOZ') ?? '', 'prefetch') === 0 ||
307
-		       strcasecmp($this->headers->get('Purpose') ?? '', 'prefetch') === 0;
308
-	}
309
-
310
-	/**
311
-	 * Checks if the method request is of specified type.
312
-	 * 
313
-	 * @param  string  $method
314
-	 * 
315
-	 * @return bool
316
-	 */
317
-	public function isMethod(string $method): bool
318
-	{
319
-		return $this->getMethod() === strtoupper($method);
320
-	}
321
-
322
-	/**
299
+    /**
300
+     * Determine if the request is the result of a prefetch call.
301
+     * 
302
+     * @return bool
303
+     */
304
+    public function prefetch(): bool
305
+    {
306
+        return strcasecmp($this->server->get('HTTP_X_MOZ') ?? '', 'prefetch') === 0 ||
307
+               strcasecmp($this->headers->get('Purpose') ?? '', 'prefetch') === 0;
308
+    }
309
+
310
+    /**
311
+     * Checks if the method request is of specified type.
312
+     * 
313
+     * @param  string  $method
314
+     * 
315
+     * @return bool
316
+     */
317
+    public function isMethod(string $method): bool
318
+    {
319
+        return $this->getMethod() === strtoupper($method);
320
+    }
321
+
322
+    /**
323 323
      * Alias of the request method.
324 324
      * 
325 325
      * @return string
@@ -329,414 +329,414 @@  discard block
 block discarded – undo
329 329
         return $this->getMethod();
330 330
     }
331 331
 
332
-	/**
333
-	 * Returns the input method used (GET, POST, DELETE, etc.).
334
-	 *
335
-	 * @return string
336
-	 * 
337
-	 * @throws \LogicException  
338
-	 */
339
-	public function getmethod(): string
340
-	{
341
-		if (null !== $this->method) {
342
-			return $this->method;
343
-		}
332
+    /**
333
+     * Returns the input method used (GET, POST, DELETE, etc.).
334
+     *
335
+     * @return string
336
+     * 
337
+     * @throws \LogicException  
338
+     */
339
+    public function getmethod(): string
340
+    {
341
+        if (null !== $this->method) {
342
+            return $this->method;
343
+        }
344 344
 		
345
-		$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
345
+        $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
346 346
 		
347
-		if ('POST' !== $this->method) {
348
-			return $this->method;
349
-		}
347
+        if ('POST' !== $this->method) {
348
+            return $this->method;
349
+        }
350 350
 		
351
-		$method = $this->headers->get('X-HTTP-METHOD-OVERRIDE');
351
+        $method = $this->headers->get('X-HTTP-METHOD-OVERRIDE');
352 352
 		
353
-		if ( ! $method && self::$httpMethodParameterOverride) {
354
-			$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
355
-		}
353
+        if ( ! $method && self::$httpMethodParameterOverride) {
354
+            $method = $this->request->get('_method', $this->query->get('_method', 'POST'));
355
+        }
356 356
 		
357
-		if ( ! is_string($method)) {
358
-			return $this->method;
359
-		}
357
+        if ( ! is_string($method)) {
358
+            return $this->method;
359
+        }
360 360
 		
361
-		$method = strtoupper($method);
361
+        $method = strtoupper($method);
362 362
 		
363
-		if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
364
-			return $this->method = $method;
365
-		}
363
+        if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
364
+            return $this->method = $method;
365
+        }
366 366
 		
367
-		if ( ! preg_match('/^[A-Z]++$/D', $method)) {
368
-			throw new LogicException(sprintf('Invalid method override "%s".', $method));
369
-		}
367
+        if ( ! preg_match('/^[A-Z]++$/D', $method)) {
368
+            throw new LogicException(sprintf('Invalid method override "%s".', $method));
369
+        }
370 370
 		
371
-		return $this->method = $method;
372
-	}
373
-
374
-	/**
375
-	 * Sets the request method.
376
-	 *
377
-	 * @param  string  $method  
378
-	 *
379
-	 * @return void
380
-	 */
381
-	public function setMethod(string $method): void
382
-	{
383
-		$this->method = null;
384
-
385
-		$this->server->set('REQUEST_METHOD', $method);
386
-	}
387
-
388
-	/**
389
-	 * Get the input source for the request.
390
-	 * 
391
-	 * @return \Syscodes\Components\Http\Loaders\Parameters
392
-	 */
393
-	public function getInputSource()
394
-	{
395
-		if ($this->isJson()) {
396
-			return $this->json();
397
-		}
398
-
399
-		return in_array($this->getMethod(), ['GET', 'HEAD']) ? $this->query : $this->request;
400
-	}
371
+        return $this->method = $method;
372
+    }
373
+
374
+    /**
375
+     * Sets the request method.
376
+     *
377
+     * @param  string  $method  
378
+     *
379
+     * @return void
380
+     */
381
+    public function setMethod(string $method): void
382
+    {
383
+        $this->method = null;
384
+
385
+        $this->server->set('REQUEST_METHOD', $method);
386
+    }
387
+
388
+    /**
389
+     * Get the input source for the request.
390
+     * 
391
+     * @return \Syscodes\Components\Http\Loaders\Parameters
392
+     */
393
+    public function getInputSource()
394
+    {
395
+        if ($this->isJson()) {
396
+            return $this->json();
397
+        }
398
+
399
+        return in_array($this->getMethod(), ['GET', 'HEAD']) ? $this->query : $this->request;
400
+    }
401 401
 	
402
-	/**
403
-	 * Determine if the current request URI matches a pattern.
404
-	 * 
405
-	 * @param  mixed  ...$patterns
406
-	 * 
407
-	 * @return bool
408
-	 */
409
-	public function is(...$patterns): bool
410
-	{
411
-		$path = $this->decodedPath();
402
+    /**
403
+     * Determine if the current request URI matches a pattern.
404
+     * 
405
+     * @param  mixed  ...$patterns
406
+     * 
407
+     * @return bool
408
+     */
409
+    public function is(...$patterns): bool
410
+    {
411
+        $path = $this->decodedPath();
412 412
 		
413
-		foreach ($patterns as $pattern) {
414
-			if (Str::is($pattern, $path)) {
415
-				return true;
416
-			}
417
-		}
418
-
419
-		return false;
420
-	}
421
-
422
-	/**
423
-	 * Determine if the route name matches a given pattern.
424
-	 * 
425
-	 * @param  mixed  ...$patterns
426
-	 * 
427
-	 * @return bool
428
-	 */
429
-	public function routeIs(...$patterns): bool
430
-	{
431
-		return $this->route() && $this->route()->is(...$patterns);
432
-	}
433
-
434
-	/**
435
-	 * Get the route handling the request.
436
-	 * 
437
-	 * @param  string|null  $param  
438
-	 * @param  mixed  $default  
439
-	 * 
440
-	 * @return \Syscodes\Components\Routing\Route|object|string|null
441
-	 */
442
-	public function route($param = null, $default = null)
443
-	{
444
-		$route = call_user_func($this->getRouteResolver());
445
-
446
-		if (is_null($route) || is_null($param)) {
447
-			return $route;
448
-		}
449
-
450
-		return $route->parameter($param, $default);
451
-	}
452
-
453
-	/**
454
-	 * Get the current decoded path info for the request.
455
-	 * 
456
-	 * @return string
457
-	 */
458
-	public function decodedPath(): string
459
-	{
460
-		return rawurldecode($this->path());
461
-	}
462
-
463
-	/**
464
-	 * Get the current path info for the request.
465
-	 * 
466
-	 * @return string
467
-	 */
468
-	public function path(): string
469
-	{
470
-		$path = trim($this->getPathInfo(), '/');
471
-
472
-		return $path == '' ? '/' : $path;
473
-	}
474
-
475
-	/**
476
-	 * Get the full URL for the request.
477
-	 * 
478
-	 * @return string
479
-	 */
480
-	public function fullUrl(): string
481
-	{
482
-		$query = $this->getQueryString();
413
+        foreach ($patterns as $pattern) {
414
+            if (Str::is($pattern, $path)) {
415
+                return true;
416
+            }
417
+        }
418
+
419
+        return false;
420
+    }
421
+
422
+    /**
423
+     * Determine if the route name matches a given pattern.
424
+     * 
425
+     * @param  mixed  ...$patterns
426
+     * 
427
+     * @return bool
428
+     */
429
+    public function routeIs(...$patterns): bool
430
+    {
431
+        return $this->route() && $this->route()->is(...$patterns);
432
+    }
433
+
434
+    /**
435
+     * Get the route handling the request.
436
+     * 
437
+     * @param  string|null  $param  
438
+     * @param  mixed  $default  
439
+     * 
440
+     * @return \Syscodes\Components\Routing\Route|object|string|null
441
+     */
442
+    public function route($param = null, $default = null)
443
+    {
444
+        $route = call_user_func($this->getRouteResolver());
445
+
446
+        if (is_null($route) || is_null($param)) {
447
+            return $route;
448
+        }
449
+
450
+        return $route->parameter($param, $default);
451
+    }
452
+
453
+    /**
454
+     * Get the current decoded path info for the request.
455
+     * 
456
+     * @return string
457
+     */
458
+    public function decodedPath(): string
459
+    {
460
+        return rawurldecode($this->path());
461
+    }
462
+
463
+    /**
464
+     * Get the current path info for the request.
465
+     * 
466
+     * @return string
467
+     */
468
+    public function path(): string
469
+    {
470
+        $path = trim($this->getPathInfo(), '/');
471
+
472
+        return $path == '' ? '/' : $path;
473
+    }
474
+
475
+    /**
476
+     * Get the full URL for the request.
477
+     * 
478
+     * @return string
479
+     */
480
+    public function fullUrl(): string
481
+    {
482
+        $query = $this->getQueryString();
483 483
 		
484
-		$question = $this->getBaseUrl().$this->getPathInfo() === '/' ? '/?' : '?';
484
+        $question = $this->getBaseUrl().$this->getPathInfo() === '/' ? '/?' : '?';
485 485
 		
486
-		return $query ? $this->url().$question.$query : $this->url();
487
-	}
486
+        return $query ? $this->url().$question.$query : $this->url();
487
+    }
488 488
 	
489
-	/**
490
-	 * Generates the normalized query string for the Request.
491
-	 * 
492
-	 * @return string
493
-	 */
494
-	public function getQueryString(): ?string
495
-	{
496
-		$queryString = RequestUtils::normalizedQueryString($this->server->get('QUERY_STRING'));
489
+    /**
490
+     * Generates the normalized query string for the Request.
491
+     * 
492
+     * @return string
493
+     */
494
+    public function getQueryString(): ?string
495
+    {
496
+        $queryString = RequestUtils::normalizedQueryString($this->server->get('QUERY_STRING'));
497 497
 		
498
-		return '' === $queryString ? null : $queryString;
499
-	}
500
-
501
-	/**
502
-	 * Retunrs the request body content.
503
-	 * 
504
-	 * @return string
505
-	 */
506
-	public function getContent(): string
507
-	{
508
-		if (null === $this->content || false === $this->content) {
509
-			$this->content = file_get_contents('php://input');
510
-		}
511
-
512
-		return $this->content;
513
-	}
514
-
515
-	/**
516
-	 * Returns the path being requested relative to the executed script. 
517
-	 * 
518
-	 * @return string
519
-	 */
520
-	public function getPathInfo(): string
521
-	{
522
-		if (null === $this->pathInfo) {
523
-			$this->pathInfo = $this->parsePathInfo();
524
-		}
525
-
526
-		return $this->pathInfo;
527
-	}
528
-
529
-	/**
530
-	 * Returns the root URL from which this request is executed.
531
-	 * 
532
-	 * @return string
533
-	 */
534
-	public function getBaseUrl(): string
535
-	{
536
-		if (null === $this->baseUrl) {
537
-			$this->baseUrl = $this->parseBaseUrl();
538
-		}
539
-
540
-		return $this->baseUrl;
541
-	}
542
-
543
-	/**
544
-	 * Returns the requested URI.
545
-	 * 
546
-	 * @return string
547
-	 */
548
-	public function getRequestUri(): string
549
-	{
550
-		if (null === $this->requestToUri) {
551
-			$this->requestToUri = $this->parseRequestUri();
552
-		}
553
-
554
-		return $this->requestToUri;
555
-	}
498
+        return '' === $queryString ? null : $queryString;
499
+    }
500
+
501
+    /**
502
+     * Retunrs the request body content.
503
+     * 
504
+     * @return string
505
+     */
506
+    public function getContent(): string
507
+    {
508
+        if (null === $this->content || false === $this->content) {
509
+            $this->content = file_get_contents('php://input');
510
+        }
511
+
512
+        return $this->content;
513
+    }
514
+
515
+    /**
516
+     * Returns the path being requested relative to the executed script. 
517
+     * 
518
+     * @return string
519
+     */
520
+    public function getPathInfo(): string
521
+    {
522
+        if (null === $this->pathInfo) {
523
+            $this->pathInfo = $this->parsePathInfo();
524
+        }
525
+
526
+        return $this->pathInfo;
527
+    }
528
+
529
+    /**
530
+     * Returns the root URL from which this request is executed.
531
+     * 
532
+     * @return string
533
+     */
534
+    public function getBaseUrl(): string
535
+    {
536
+        if (null === $this->baseUrl) {
537
+            $this->baseUrl = $this->parseBaseUrl();
538
+        }
539
+
540
+        return $this->baseUrl;
541
+    }
542
+
543
+    /**
544
+     * Returns the requested URI.
545
+     * 
546
+     * @return string
547
+     */
548
+    public function getRequestUri(): string
549
+    {
550
+        if (null === $this->requestToUri) {
551
+            $this->requestToUri = $this->parseRequestUri();
552
+        }
553
+
554
+        return $this->requestToUri;
555
+    }
556 556
 	
557
-	/**
558
-	 * Generates a normalized URI (URL) for the Request.
559
-	 * 
560
-	 * @return string
561
-	 */
562
-	public function getUri(): string
563
-	{
564
-		if (null !== $query = $this->getQueryString()) {
565
-			$query = '?'.$query;
566
-		}
557
+    /**
558
+     * Generates a normalized URI (URL) for the Request.
559
+     * 
560
+     * @return string
561
+     */
562
+    public function getUri(): string
563
+    {
564
+        if (null !== $query = $this->getQueryString()) {
565
+            $query = '?'.$query;
566
+        }
567 567
 	
568
-		return $this->getSchemeWithHttpHost().$this->getBaseUrl().$this->getPathInfo().$query;
569
-	}
570
-
571
-	/**
572
-	 * Get the root URL for the application.
573
-	 * 
574
-	 * @return string
575
-	 */
576
-	public function root(): string
577
-	{
578
-		return rtrim($this->getSchemeWithHttpHost().$this->getBaseUrl(), '/');
579
-	}
580
-
581
-	/**
582
-	 * Get the URL for the request.
583
-	 * 
584
-	 * @return string
585
-	 */
586
-	public function url(): string
587
-	{
588
-		// Changed $this->path() for $this->getUri()
589
-		return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
590
-	}
591
-
592
-	/**
593
-	 * Returns the referer.
594
-	 * 
595
-	 * @param  string  $default
596
-	 * 
597
-	 * @return string
598
-	 */
599
-	public function referer(string $default = ''): string
600
-	{
601
-		return $this->server->get('HTTP_REFERER', $default);
602
-	}
568
+        return $this->getSchemeWithHttpHost().$this->getBaseUrl().$this->getPathInfo().$query;
569
+    }
570
+
571
+    /**
572
+     * Get the root URL for the application.
573
+     * 
574
+     * @return string
575
+     */
576
+    public function root(): string
577
+    {
578
+        return rtrim($this->getSchemeWithHttpHost().$this->getBaseUrl(), '/');
579
+    }
580
+
581
+    /**
582
+     * Get the URL for the request.
583
+     * 
584
+     * @return string
585
+     */
586
+    public function url(): string
587
+    {
588
+        // Changed $this->path() for $this->getUri()
589
+        return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
590
+    }
591
+
592
+    /**
593
+     * Returns the referer.
594
+     * 
595
+     * @param  string  $default
596
+     * 
597
+     * @return string
598
+     */
599
+    public function referer(string $default = ''): string
600
+    {
601
+        return $this->server->get('HTTP_REFERER', $default);
602
+    }
603 603
 	
604
-	/**
605
-	 * Attempts to detect if the current connection is secure through 
606
-	 * over HTTPS protocol.
607
-	 * 
608
-	 * @return bool
609
-	 */
610
-	public function secure(): bool
611
-	{
612
-		if ( ! empty($this->server->get('HTTPS')) && strtolower($this->server->get('HTTPS')) !== 'off') {
613
-			return true;
614
-		} elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $this->server->get('HTTP_X_FORWARDED_PROTO') === 'https') {
615
-			return true;
616
-		} elseif ( ! empty($this->server->get('HTTP_FRONT_END_HTTPS')) && strtolower($this->server->get('HTTP_FRONT_END_HTTPS')) !== 'off') {
617
-			return true;
618
-		}
619
-
620
-		return false;
621
-	}
622
-
623
-	/**
624
-	 * Returns the user agent.
625
-	 *
626
-	 * @param  string|null  $default
627
-	 *
628
-	 * @return string
629
-	 */
630
-	public function userAgent(string $default = null): string
631
-	{
632
-		return $this->server->get('HTTP_USER_AGENT', $default);
633
-	}
604
+    /**
605
+     * Attempts to detect if the current connection is secure through 
606
+     * over HTTPS protocol.
607
+     * 
608
+     * @return bool
609
+     */
610
+    public function secure(): bool
611
+    {
612
+        if ( ! empty($this->server->get('HTTPS')) && strtolower($this->server->get('HTTPS')) !== 'off') {
613
+            return true;
614
+        } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $this->server->get('HTTP_X_FORWARDED_PROTO') === 'https') {
615
+            return true;
616
+        } elseif ( ! empty($this->server->get('HTTP_FRONT_END_HTTPS')) && strtolower($this->server->get('HTTP_FRONT_END_HTTPS')) !== 'off') {
617
+            return true;
618
+        }
619
+
620
+        return false;
621
+    }
622
+
623
+    /**
624
+     * Returns the user agent.
625
+     *
626
+     * @param  string|null  $default
627
+     *
628
+     * @return string
629
+     */
630
+    public function userAgent(string $default = null): string
631
+    {
632
+        return $this->server->get('HTTP_USER_AGENT', $default);
633
+    }
634 634
 	
635
-	/**
636
-	 * Get the client IP address.
637
-	 * 
638
-	 * @return string|null
639
-	 */
640
-	public function ip(): ?string
641
-	{
642
-		return $this->clientIp->getClientIp();
643
-	}
644
-
645
-	/**
646
-	 * Get the route resolver callback.
647
-	 * 
648
-	 * @return \Closure
649
-	 */
650
-	public function getRouteResolver(): Closure
651
-	{
652
-		return $this->routeResolver ?: function () {
653
-			//
654
-		};
655
-	}
656
-
657
-	/**
658
-	 * Set the route resolver callback.
659
-	 * 
660
-	 * @param  \Closure  $callback
661
-	 * 
662
-	 * @return static
663
-	 */
664
-	public function setRouteResolver(Closure $callback): static
665
-	{
666
-		$this->routeResolver = $callback;
667
-
668
-		return $this;
669
-	}
635
+    /**
636
+     * Get the client IP address.
637
+     * 
638
+     * @return string|null
639
+     */
640
+    public function ip(): ?string
641
+    {
642
+        return $this->clientIp->getClientIp();
643
+    }
644
+
645
+    /**
646
+     * Get the route resolver callback.
647
+     * 
648
+     * @return \Closure
649
+     */
650
+    public function getRouteResolver(): Closure
651
+    {
652
+        return $this->routeResolver ?: function () {
653
+            //
654
+        };
655
+    }
656
+
657
+    /**
658
+     * Set the route resolver callback.
659
+     * 
660
+     * @param  \Closure  $callback
661
+     * 
662
+     * @return static
663
+     */
664
+    public function setRouteResolver(Closure $callback): static
665
+    {
666
+        $this->routeResolver = $callback;
667
+
668
+        return $this;
669
+    }
670 670
 	
671
-	/**
672
-	 * Magic method.
673
-	 * 
674
-	 * Check if an input element is set on the request.
675
-	 * 
676
-	 * @param  string  $key
677
-	 * 
678
-	 * @return bool
679
-	 */
680
-	public function __isset($key)
681
-	{
682
-		return ! is_null($this->__get($key));
683
-	}
684
-
685
-	/**
686
-	 * Magic method.
687
-	 * 
688
-	 * Get an element from the request.
689
-	 * 
690
-	 * @return string[]
691
-	 */
692
-	public function __get($key)
693
-	{
694
-		return Arr::get($this->all(), $key, fn () => $this->route($key));
695
-	}
696
-
697
-	/**
698
-	 * Magic method.
699
-	 * 
700
-	 * Returns the Request as an HTTP string.
701
-	 * 
702
-	 * @return string
703
-	 */
704
-	public function __toString(): string
705
-	{
706
-		$content = $this->getContent();
707
-
708
-		$cookieHeader = '';
709
-		$cookies      = [];
710
-
711
-		foreach ($this->cookies as $key => $value) {
712
-			$cookies[]= is_array($value) ? http_build_query([$key => $value], '', '; ', PHP_QUERY_RFC3986) : "$key=$value";
713
-		}
714
-
715
-		if ($cookies) {
716
-			$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
717
-		}
671
+    /**
672
+     * Magic method.
673
+     * 
674
+     * Check if an input element is set on the request.
675
+     * 
676
+     * @param  string  $key
677
+     * 
678
+     * @return bool
679
+     */
680
+    public function __isset($key)
681
+    {
682
+        return ! is_null($this->__get($key));
683
+    }
684
+
685
+    /**
686
+     * Magic method.
687
+     * 
688
+     * Get an element from the request.
689
+     * 
690
+     * @return string[]
691
+     */
692
+    public function __get($key)
693
+    {
694
+        return Arr::get($this->all(), $key, fn () => $this->route($key));
695
+    }
696
+
697
+    /**
698
+     * Magic method.
699
+     * 
700
+     * Returns the Request as an HTTP string.
701
+     * 
702
+     * @return string
703
+     */
704
+    public function __toString(): string
705
+    {
706
+        $content = $this->getContent();
707
+
708
+        $cookieHeader = '';
709
+        $cookies      = [];
710
+
711
+        foreach ($this->cookies as $key => $value) {
712
+            $cookies[]= is_array($value) ? http_build_query([$key => $value], '', '; ', PHP_QUERY_RFC3986) : "$key=$value";
713
+        }
714
+
715
+        if ($cookies) {
716
+            $cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
717
+        }
718 718
 		
719
-		return sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
720
-			$this->headers.
721
-			$cookieHeader."\r\n".
722
-			$content;
723
-	}
724
-
725
-	/**
726
-	 * Magic method.
727
-	 * 
728
-	 * Clones the current request.
729
-	 * 
730
-	 * @return void
731
-	 */
732
-	public function __clone()
733
-	{
734
-		$this->query      = clone $this->query;
735
-		$this->request    = clone $this->request;
736
-		$this->attributes = clone $this->attributes;
737
-		$this->cookies    = clone $this->cookies;
738
-		$this->files      = clone $this->files;
739
-		$this->server     = clone $this->server;
740
-		$this->headers    = clone $this->headers;
741
-	}
719
+        return sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
720
+            $this->headers.
721
+            $cookieHeader."\r\n".
722
+            $content;
723
+    }
724
+
725
+    /**
726
+     * Magic method.
727
+     * 
728
+     * Clones the current request.
729
+     * 
730
+     * @return void
731
+     */
732
+    public function __clone()
733
+    {
734
+        $this->query      = clone $this->query;
735
+        $this->request    = clone $this->request;
736
+        $this->attributes = clone $this->attributes;
737
+        $this->cookies    = clone $this->cookies;
738
+        $this->files      = clone $this->files;
739
+        $this->server     = clone $this->server;
740
+        $this->headers    = clone $this->headers;
741
+    }
742 742
 }
743 743
\ 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
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	 */
650 650
 	public function getRouteResolver(): Closure
651 651
 	{
652
-		return $this->routeResolver ?: function () {
652
+		return $this->routeResolver ?: function() {
653 653
 			//
654 654
 		};
655 655
 	}
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 		$cookies      = [];
710 710
 
711 711
 		foreach ($this->cookies as $key => $value) {
712
-			$cookies[]= is_array($value) ? http_build_query([$key => $value], '', '; ', PHP_QUERY_RFC3986) : "$key=$value";
712
+			$cookies[] = is_array($value) ? http_build_query([$key => $value], '', '; ', PHP_QUERY_RFC3986) : "$key=$value";
713 713
 		}
714 714
 
715 715
 		if ($cookies) {
Please login to merge, or discard this patch.
src/components/Core/Exceptions/Debugging/DebugExceptionRender.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public function render($exception): string
43 43
     {
44
-        return take(new GDebug, function ($debug) {
44
+        return take(new GDebug, function($debug) {
45 45
             
46 46
             $debug->appendHandler($this->DebugHandler());
47 47
 
Please login to merge, or discard this patch.
components/Debug/Exceptions/Resources/views/partials/frames/frame_list.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
8 8
 			<div class="frame-info-class">
9 9
 			<?php if ($frame->getClass() == '') : ?>
10 10
 				<span class="frame-function"><?= e($frame->getFunction()) ?></span>
11
-			<?php else: ?>
11
+			<?php else {
12
+    : ?>
12 13
 				<span class="frame-class"><?= e($frame->getClass()) ?></span>
13 14
 				<?php if ($frame->getFunction() != '') : ?>
14 15
 				<span class="frame-function"><?= e($frame->getFunction()) ?></span>
@@ -20,5 +21,7 @@  discard block
 block discarded – undo
20 21
 			<span class="frame-line"><?= (int) $frame->getLine() ?></span>
21 22
 		</div>		
22 23
 	</div>		
23
-<?php endforeach; ?>	
24
+<?php endforeach;
25
+}
26
+?>	
24 27
 </aside>
25 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Stopwatch/Benchmark.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
         $seconds  = (int) ($duration - $hours * 60 * 60 - $minutes * 60); 
144 144
         
145 145
         if ($seconds <= 0) {
146
-           return ' ms';
146
+            return ' ms';
147 147
         } elseif ($seconds > 0) {
148 148
             return ' s';
149 149
         }
Please login to merge, or discard this patch.
src/components/Encryption/EncryptionServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function register()
41 41
     {
42
-        $this->app->singleton('encrypter', function ($app) {            
42
+        $this->app->singleton('encrypter', function($app) {            
43 43
             $config = $app->make('config')->get('security');
44 44
             
45 45
             return new Encrypter($this->parseKey($config), $config['cipher']);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function key(array $config)
75 75
     {
76
-        return take($config['key'], function ($key) {
76
+        return take($config['key'], function($key) {
77 77
             if (empty($key)) {
78 78
                 throw new MissingAppKeyException;
79 79
             }            
Please login to merge, or discard this patch.
src/components/Debug/Exceptions/FrameHandler/Supervisor.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -31,156 +31,156 @@
 block discarded – undo
31 31
  */
32 32
 class Supervisor
33 33
 {
34
-	/**
35
-	 * Get exception. 
36
-	 * 
37
-	 * @var \Throwable $exception
38
-	 */
39
-	protected $exception;
40
-
41
-	/**
42
-	 * The frame execute errors.
43
-	 * 
44
-	 * @var string $frames
45
-	 */
46
-	protected $frames;
47
-
48
-	/**
49
-	 * Constructor. The Supervisor class instance.
50
-	 * 
51
-	 * @param  \Throwable  $exception
52
-	 * 
53
-	 * @return string
54
-	 */
55
-	public function __construct($exception)
56
-	{
57
-		$this->exception = $exception;
58
-	}
34
+    /**
35
+     * Get exception. 
36
+     * 
37
+     * @var \Throwable $exception
38
+     */
39
+    protected $exception;
40
+
41
+    /**
42
+     * The frame execute errors.
43
+     * 
44
+     * @var string $frames
45
+     */
46
+    protected $frames;
47
+
48
+    /**
49
+     * Constructor. The Supervisor class instance.
50
+     * 
51
+     * @param  \Throwable  $exception
52
+     * 
53
+     * @return string
54
+     */
55
+    public function __construct($exception)
56
+    {
57
+        $this->exception = $exception;
58
+    }
59 59
 	
60
-	/**
61
-	 * Returns an iterator for the inspected exception's frames.
62
-	 * 
63
-	 * @param  \Throwable  $exception
64
-	 * 
65
-	 * @return array 
66
-	 */
67
-	public function getFrames()
68
-	{
69
-		if ($this->frames === null) {
70
-			$frames = $this->getTrace($this->exception);	
71
-
72
-			// Fill empty line/file info for call_user_func_array usages 
73
-			foreach ($frames as $k => $frame) {
74
-				if (empty($frame['file'])) {
75
-					// Default values when file and line are missing
76
-					$file = '[PHP internal Code]';
77
-					$line = 0;
78
-					$next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : [];
79
-					$frames[$k]['file'] = $file;
80
-					$frames[$k]['line'] = $line;
81
-				}
82
-			}
60
+    /**
61
+     * Returns an iterator for the inspected exception's frames.
62
+     * 
63
+     * @param  \Throwable  $exception
64
+     * 
65
+     * @return array 
66
+     */
67
+    public function getFrames()
68
+    {
69
+        if ($this->frames === null) {
70
+            $frames = $this->getTrace($this->exception);	
71
+
72
+            // Fill empty line/file info for call_user_func_array usages 
73
+            foreach ($frames as $k => $frame) {
74
+                if (empty($frame['file'])) {
75
+                    // Default values when file and line are missing
76
+                    $file = '[PHP internal Code]';
77
+                    $line = 0;
78
+                    $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : [];
79
+                    $frames[$k]['file'] = $file;
80
+                    $frames[$k]['line'] = $line;
81
+                }
82
+            }
83 83
 			
84
-			// Find latest non-error handling frame index ($i) used to remove error handling frames
85
-			$i = 0;
86
-
87
-			foreach ($frames as $k => $frame) {
88
-				if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) {
89
-					$i = $k;
90
-				}
91
-			}
92
-			// Remove error handling frames
93
-			if ($i > 0) {
94
-				array_splice($frames, 0, $i);
95
-			}
84
+            // Find latest non-error handling frame index ($i) used to remove error handling frames
85
+            $i = 0;
86
+
87
+            foreach ($frames as $k => $frame) {
88
+                if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) {
89
+                    $i = $k;
90
+                }
91
+            }
92
+            // Remove error handling frames
93
+            if ($i > 0) {
94
+                array_splice($frames, 0, $i);
95
+            }
96 96
 	
97
-			$firstFrame = $this->getFrameFromException($this->exception);	
98
-			array_unshift($frames, $firstFrame);
99
-
100
-			$this->frames = new Collection($frames);
101
-		}
102
-
103
-		return $this->frames;
104
-	}
105
-
106
-	/**
107
-	 * Given an exception, generates an array in the format generated by Exception::getTrace().
108
-	 * 
109
-	 * @param  \Throwable  $exception
110
-	 * 
111
-	 * @return array
112
-	 */
113
-	protected function getFrameFromException(Throwable $exception): array
114
-	{
115
-		return [
116
-			'file'  => $exception->getFile(),
117
-			'line'  => $exception->getLine(),
118
-			'class' => getClass($exception),
119
-			'code'  => $exception->getCode(),
120
-			'args'  => [
121
-				$exception->getMessage(),
122
-			],
123
-		];
124
-	}
125
-
126
-	/**
127
-	 * Gets exception already specified.
128
-	 * 
129
-	 * @return \Throwable
130
-	 */
131
-	public function getException()
132
-	{
133
-		return $this->exception;
134
-	}
135
-
136
-	/**
137
-	 * Gets the message of exception.
138
-	 * 
139
-	 * @return string
140
-	 */
141
-	public function getExceptionMessage(): string
142
-	{
143
-		return $this->exception->getMessage();
144
-	}
145
-
146
-	/**
147
-	 * Gets the class name of exception.
148
-	 * 
149
-	 * @return mixed
150
-	 */
151
-	public function getExceptionName()
152
-	{
153
-		return getClass($this->exception, true);
154
-	}
97
+            $firstFrame = $this->getFrameFromException($this->exception);	
98
+            array_unshift($frames, $firstFrame);
99
+
100
+            $this->frames = new Collection($frames);
101
+        }
102
+
103
+        return $this->frames;
104
+    }
105
+
106
+    /**
107
+     * Given an exception, generates an array in the format generated by Exception::getTrace().
108
+     * 
109
+     * @param  \Throwable  $exception
110
+     * 
111
+     * @return array
112
+     */
113
+    protected function getFrameFromException(Throwable $exception): array
114
+    {
115
+        return [
116
+            'file'  => $exception->getFile(),
117
+            'line'  => $exception->getLine(),
118
+            'class' => getClass($exception),
119
+            'code'  => $exception->getCode(),
120
+            'args'  => [
121
+                $exception->getMessage(),
122
+            ],
123
+        ];
124
+    }
125
+
126
+    /**
127
+     * Gets exception already specified.
128
+     * 
129
+     * @return \Throwable
130
+     */
131
+    public function getException()
132
+    {
133
+        return $this->exception;
134
+    }
135
+
136
+    /**
137
+     * Gets the message of exception.
138
+     * 
139
+     * @return string
140
+     */
141
+    public function getExceptionMessage(): string
142
+    {
143
+        return $this->exception->getMessage();
144
+    }
145
+
146
+    /**
147
+     * Gets the class name of exception.
148
+     * 
149
+     * @return mixed
150
+     */
151
+    public function getExceptionName()
152
+    {
153
+        return getClass($this->exception, true);
154
+    }
155 155
 	
156
-	/**
157
-	 * Gets the backtrace from an exception.
158
-	 * 
159
-	 * @param  \Throwable  $exception
160
-	 * 
161
-	 * @return array
162
-	 */
163
-	protected function getTrace($exception): array
164
-	{
165
-		$traces = $exception->getTrace();
166
-
167
-		if ( ! $exception instanceof ErrorException) {
168
-			return $traces;
169
-		}
170
-
171
-		if ( ! Misc::isFatalError($exception->getSeverity())) {
172
-			return $traces;
173
-		}
174
-
175
-		if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) {
176
-			return $traces;
177
-		}
156
+    /**
157
+     * Gets the backtrace from an exception.
158
+     * 
159
+     * @param  \Throwable  $exception
160
+     * 
161
+     * @return array
162
+     */
163
+    protected function getTrace($exception): array
164
+    {
165
+        $traces = $exception->getTrace();
166
+
167
+        if ( ! $exception instanceof ErrorException) {
168
+            return $traces;
169
+        }
170
+
171
+        if ( ! Misc::isFatalError($exception->getSeverity())) {
172
+            return $traces;
173
+        }
174
+
175
+        if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) {
176
+            return $traces;
177
+        }
178 178
 		
179
-		// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
180
-		$stack = array_reverse(xdebug_get_function_stack());
181
-		$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
182
-		$traces = array_diff_key($stack, $trace);
179
+        // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
180
+        $stack = array_reverse(xdebug_get_function_stack());
181
+        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
182
+        $traces = array_diff_key($stack, $trace);
183 183
 		
184
-		return $traces;
185
-	}
184
+        return $traces;
185
+    }
186 186
 }
187 187
\ No newline at end of file
Please login to merge, or discard this patch.