Passed
Push — master ( fca16e...a09e23 )
by Alexander
04:10
created
src/components/Http/Resources/HttpResources.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -29,211 +29,211 @@
 block discarded – undo
29 29
  */
30 30
 trait HttpResources
31 31
 {
32
-	/**
33
-	 * Filters a value from the start of a string in this case the passed URI string.
34
-	 *
35
-	 * @return string
36
-	 */
37
-	protected function parseRequestUri(): string
38
-	{
39
-		$requestUri = '';
40
-		
41
-		if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
42
-			// IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
43
-			$requestUri = $this->server->get('UNENCODED_URL');
44
-			$this->server->remove('UNENCODED_URL');
45
-			$this->server->remove('IIS_WasUrlRewritten');
46
-		} elseif ($this->server->has('REQUEST_URI')) {
47
-			$requestUri = $this->server->get('REQUEST_URI');
32
+    /**
33
+     * Filters a value from the start of a string in this case the passed URI string.
34
+     *
35
+     * @return string
36
+     */
37
+    protected function parseRequestUri(): string
38
+    {
39
+        $requestUri = '';
40
+		
41
+        if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
42
+            // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
43
+            $requestUri = $this->server->get('UNENCODED_URL');
44
+            $this->server->remove('UNENCODED_URL');
45
+            $this->server->remove('IIS_WasUrlRewritten');
46
+        } elseif ($this->server->has('REQUEST_URI')) {
47
+            $requestUri = $this->server->get('REQUEST_URI');
48 48
 			
49
-			if ('' !== $requestUri && '/' === $requestUri[0]) {
50
-				// To only use path and query remove the fragment.
51
-				if (false !== $pos = strpos($requestUri, '#')) {
52
-					$requestUri = substr($requestUri, 0, $pos);
53
-				}
54
-			} else {
55
-				// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
56
-				// only use URL path.
57
-				$uriComponents = parse_url($requestUri);
49
+            if ('' !== $requestUri && '/' === $requestUri[0]) {
50
+                // To only use path and query remove the fragment.
51
+                if (false !== $pos = strpos($requestUri, '#')) {
52
+                    $requestUri = substr($requestUri, 0, $pos);
53
+                }
54
+            } else {
55
+                // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
56
+                // only use URL path.
57
+                $uriComponents = parse_url($requestUri);
58 58
 				
59
-				if (isset($uriComponents['path'])) {
60
-					$requestUri = $uriComponents['path'];
61
-				}
59
+                if (isset($uriComponents['path'])) {
60
+                    $requestUri = $uriComponents['path'];
61
+                }
62 62
 				
63
-				if (isset($uriComponents['query'])) {
64
-					$requestUri .= '?'.$uriComponents['query'];
65
-				}
66
-			}
67
-		} elseif ($this->server->has('ORIG_PATH_INFO')) {
68
-			// IIS 5.0, PHP as CGI
69
-			$requestUri = $this->server->get('ORIG_PATH_INFO');
63
+                if (isset($uriComponents['query'])) {
64
+                    $requestUri .= '?'.$uriComponents['query'];
65
+                }
66
+            }
67
+        } elseif ($this->server->has('ORIG_PATH_INFO')) {
68
+            // IIS 5.0, PHP as CGI
69
+            $requestUri = $this->server->get('ORIG_PATH_INFO');
70 70
 			
71
-			if ('' != $this->server->get('QUERY_STRING')) {
72
-				$requestUri .= '?'.$this->server->get('QUERY_STRING');
73
-			}
71
+            if ('' != $this->server->get('QUERY_STRING')) {
72
+                $requestUri .= '?'.$this->server->get('QUERY_STRING');
73
+            }
74 74
 			
75
-			$this->server->remove('ORIG_PATH_INFO');
76
-		}
75
+            $this->server->remove('ORIG_PATH_INFO');
76
+        }
77 77
 		
78
-		// normalize the request URI to ease creating sub-requests from this request
79
-		$this->server->set('REQUEST_URI', $requestUri);
78
+        // normalize the request URI to ease creating sub-requests from this request
79
+        $this->server->set('REQUEST_URI', $requestUri);
80 80
 		
81
-		return $this->filterDecode($requestUri);
82
-	}
81
+        return $this->filterDecode($requestUri);
82
+    }
83 83
 
84
-	/**
85
-	 * Will parse QUERY_STRING and automatically detect the URI from it.
86
-	 * 
87
-	 * @return string
88
-	 */
89
-	protected function parseQueryString(): string
90
-	{
91
-		$uri = $_SERVER['QUERY_STRING'] ?? @getenv('QUERY_STRING');
84
+    /**
85
+     * Will parse QUERY_STRING and automatically detect the URI from it.
86
+     * 
87
+     * @return string
88
+     */
89
+    protected function parseQueryString(): string
90
+    {
91
+        $uri = $_SERVER['QUERY_STRING'] ?? @getenv('QUERY_STRING');
92 92
 
93
-		if (trim($uri, '/') === '') {
94
-			return '';
95
-		} elseif (0 === strncmp($uri, '/', 1)) {
96
-			$uri    				 = explode('?', $uri, 2);
97
-			$_SERVER['QUERY_STRING'] = $uri[1] ?? '';
98
-			$uri    				 = $uri[0] ?? '';
99
-		}
93
+        if (trim($uri, '/') === '') {
94
+            return '';
95
+        } elseif (0 === strncmp($uri, '/', 1)) {
96
+            $uri    				 = explode('?', $uri, 2);
97
+            $_SERVER['QUERY_STRING'] = $uri[1] ?? '';
98
+            $uri    				 = $uri[0] ?? '';
99
+        }
100 100
 
101
-		parse_str($_SERVER['QUERY_STRING'], $_GET);
101
+        parse_str($_SERVER['QUERY_STRING'], $_GET);
102 102
 
103
-		return $this->filterDecode($uri);
104
-	}
103
+        return $this->filterDecode($uri);
104
+    }
105 105
 	
106
-	/**
107
-	 * Parse the base URL.
108
-	 * 
109
-	 * @return string
110
-	 */
111
-	public function parseBaseUrl(): string
112
-	{
113
-		$filename = basename($this->server('SCRIPT_FILENAME'));
114
-		
115
-		if ($filename === basename($this->server('SCRIPT_NAME'))) {
116
-			$baseUrl = $this->server('SCRIPT_NAME');
117
-		} elseif ($filename === basename($this->server('PHP_SELF'))) {
118
-			$baseUrl = $this->server('PHP_SELF');
119
-		} elseif ($filename === basename($this->server('ORIG_SCRIPT_NAME'))) {
120
-			$baseUrl = $this->server('ORIG_SCRIPT_NAME');
121
-		} else {
122
-			$path    = $this->server('PHP_SELF', '');
123
-			$file    = $this->server('SCRIPT_NAME', '');
124
-			$segs    = explode('/', trim($file, '/'));
125
-			$segs    = array_reverse($segs);
126
-			$index   = 0;
127
-			$last    = count($segs);
128
-			$baseUrl = '';
106
+    /**
107
+     * Parse the base URL.
108
+     * 
109
+     * @return string
110
+     */
111
+    public function parseBaseUrl(): string
112
+    {
113
+        $filename = basename($this->server('SCRIPT_FILENAME'));
114
+		
115
+        if ($filename === basename($this->server('SCRIPT_NAME'))) {
116
+            $baseUrl = $this->server('SCRIPT_NAME');
117
+        } elseif ($filename === basename($this->server('PHP_SELF'))) {
118
+            $baseUrl = $this->server('PHP_SELF');
119
+        } elseif ($filename === basename($this->server('ORIG_SCRIPT_NAME'))) {
120
+            $baseUrl = $this->server('ORIG_SCRIPT_NAME');
121
+        } else {
122
+            $path    = $this->server('PHP_SELF', '');
123
+            $file    = $this->server('SCRIPT_NAME', '');
124
+            $segs    = explode('/', trim($file, '/'));
125
+            $segs    = array_reverse($segs);
126
+            $index   = 0;
127
+            $last    = count($segs);
128
+            $baseUrl = '';
129 129
 			
130
-			do 	{
131
-				$seg     = $segs[$index];
132
-				$baseUrl = '/'.$seg.$baseUrl;
133
-				++$index;
134
-			} while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos);
135
-		}
136
-		
137
-		// Does the baseUrl have anything in common with the request_uri?
138
-		$requestUri = $this->getRequestUri();
139
-		
140
-		if ('' !== $requestUri && '/' !== $requestUri[0]) {
141
-			$requestUri = '/'.$requestUri;
142
-		}
143
-		
144
-		if ($baseUrl && null !== $uri = $this->getUrlencoded($requestUri, $baseUrl)) {
145
-			// Full $baseUrl matches
146
-			return $this->filterDecode($uri);
147
-		}
148
-		
149
-		if ($baseUrl && null !== $uri = $this->getUrlencoded($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR))) {
150
-			// Directory portion of $baseUrl matches
151
-			return $this->filterDecode($uri);
152
-		}
130
+            do 	{
131
+                $seg     = $segs[$index];
132
+                $baseUrl = '/'.$seg.$baseUrl;
133
+                ++$index;
134
+            } while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos);
135
+        }
136
+		
137
+        // Does the baseUrl have anything in common with the request_uri?
138
+        $requestUri = $this->getRequestUri();
139
+		
140
+        if ('' !== $requestUri && '/' !== $requestUri[0]) {
141
+            $requestUri = '/'.$requestUri;
142
+        }
143
+		
144
+        if ($baseUrl && null !== $uri = $this->getUrlencoded($requestUri, $baseUrl)) {
145
+            // Full $baseUrl matches
146
+            return $this->filterDecode($uri);
147
+        }
148
+		
149
+        if ($baseUrl && null !== $uri = $this->getUrlencoded($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR))) {
150
+            // Directory portion of $baseUrl matches
151
+            return $this->filterDecode($uri);
152
+        }
153 153
 
154
-		$baseUrl = dirname($baseUrl ?? '');
154
+        $baseUrl = dirname($baseUrl ?? '');
155 155
 		
156
-		// If using mod_rewrite or ISAPI_Rewrite strip the script filename
157
-		// out of baseUrl. $pos !== 0 makes sure it is not matching a value
158
-		// from PATH_INFO or QUERY_STRING
159
-		if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
160
-			$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
161
-		}
156
+        // If using mod_rewrite or ISAPI_Rewrite strip the script filename
157
+        // out of baseUrl. $pos !== 0 makes sure it is not matching a value
158
+        // from PATH_INFO or QUERY_STRING
159
+        if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
160
+            $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
161
+        }
162 162
 		
163
-		return $this->filterDecode($baseUrl);
164
-	}
163
+        return $this->filterDecode($baseUrl);
164
+    }
165 165
 	
166
-	/**
167
-	 * Returns the prefix as encoded in the string when the string starts with
168
-	 * the given prefix, null otherwise.
169
-	 *
170
-	 * return string|null
171
-	 */
172
-	private function getUrlencoded(string $string, string $prefix): ?string
173
-	{
174
-		if ( ! Str::startsWith(rawurldecode($string), $prefix)) {
175
-			return null;
176
-		}
177
-		
178
-		$length = strlen($prefix);
179
-		
180
-		if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $length), $string, $match)) {
181
-			return $match[0];
182
-		}
183
-		
184
-		return null;
185
-	}
166
+    /**
167
+     * Returns the prefix as encoded in the string when the string starts with
168
+     * the given prefix, null otherwise.
169
+     *
170
+     * return string|null
171
+     */
172
+    private function getUrlencoded(string $string, string $prefix): ?string
173
+    {
174
+        if ( ! Str::startsWith(rawurldecode($string), $prefix)) {
175
+            return null;
176
+        }
177
+		
178
+        $length = strlen($prefix);
179
+		
180
+        if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $length), $string, $match)) {
181
+            return $match[0];
182
+        }
183
+		
184
+        return null;
185
+    }
186 186
 
187 187
 
188
-	/**
189
-	 * Parse the path info.
190
-	 * 
191
-	 * @return string
192
-	 */
193
-	public function parsePathInfo(): string
194
-	{
195
-		if (null === ($requestUri = $this->getRequestUri())) {
196
-			return '/';
197
-		}
198
-		
199
-		// Remove the query string from REQUEST_URI
200
-		if (false !== $pos = strpos($requestUri, '?')) {
201
-			$requestUri = substr($requestUri, 0, $pos);
202
-		}
203
-		
204
-		if ('' !== $requestUri && '/' !== $requestUri[0]) {
205
-			$requestUri = '/'.$requestUri;
206
-		}
207
-		
208
-		if (null === ($baseUrl = $this->getBaseUrl())) {
209
-			return $requestUri;
210
-		}
211
-		
212
-		$pathInfo = substr($requestUri, \strlen($baseUrl));
213
-		
214
-		if (false === $pathInfo || '' === $pathInfo) {
215
-			// If substr() returns false then PATH_INFO is set to an empty string
216
-			return '/';
217
-		}
218
-		
219
-		return $this->filterDecode($pathInfo);
220
-	}
188
+    /**
189
+     * Parse the path info.
190
+     * 
191
+     * @return string
192
+     */
193
+    public function parsePathInfo(): string
194
+    {
195
+        if (null === ($requestUri = $this->getRequestUri())) {
196
+            return '/';
197
+        }
198
+		
199
+        // Remove the query string from REQUEST_URI
200
+        if (false !== $pos = strpos($requestUri, '?')) {
201
+            $requestUri = substr($requestUri, 0, $pos);
202
+        }
203
+		
204
+        if ('' !== $requestUri && '/' !== $requestUri[0]) {
205
+            $requestUri = '/'.$requestUri;
206
+        }
207
+		
208
+        if (null === ($baseUrl = $this->getBaseUrl())) {
209
+            return $requestUri;
210
+        }
211
+		
212
+        $pathInfo = substr($requestUri, \strlen($baseUrl));
213
+		
214
+        if (false === $pathInfo || '' === $pathInfo) {
215
+            // If substr() returns false then PATH_INFO is set to an empty string
216
+            return '/';
217
+        }
218
+		
219
+        return $this->filterDecode($pathInfo);
220
+    }
221 221
 
222
-	/**
223
-	 * Filters the uri string remove any malicious characters and inappropriate slashes.
224
-	 *
225
-	 * @param  string  $uri
226
-	 *
227
-	 * @return string
228
-	 */
229
-	protected function filterDecode($uri): string
230
-	{
231
-		// Remove all characters except letters,
232
-		// digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=.
233
-		$uri = filter_var(rawurldecode($uri), FILTER_SANITIZE_URL);
234
-		$uri = mb_strtolower(trim($uri), 'UTF-8');
235
-		
236
-		// Return argument if not empty or return a single slash
237
-		return trim($uri);
238
-	}
222
+    /**
223
+     * Filters the uri string remove any malicious characters and inappropriate slashes.
224
+     *
225
+     * @param  string  $uri
226
+     *
227
+     * @return string
228
+     */
229
+    protected function filterDecode($uri): string
230
+    {
231
+        // Remove all characters except letters,
232
+        // digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=.
233
+        $uri = filter_var(rawurldecode($uri), FILTER_SANITIZE_URL);
234
+        $uri = mb_strtolower(trim($uri), 'UTF-8');
235
+		
236
+        // Return argument if not empty or return a single slash
237
+        return trim($uri);
238
+    }
239 239
 }
240 240
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@
 block discarded – undo
127 127
 			$last    = count($segs);
128 128
 			$baseUrl = '';
129 129
 			
130
-			do 	{
130
+			do {
131 131
 				$seg     = $segs[$index];
132 132
 				$baseUrl = '/'.$seg.$baseUrl;
133 133
 				++$index;
Please login to merge, or discard this patch.
src/components/Http/Resources/HttpRequest.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -31,33 +31,33 @@  discard block
 block discarded – undo
31 31
  */
32 32
 trait HttpRequest
33 33
 {
34
-	/**
35
-	 * Holds the global active request instance.
36
-	 *
37
-	 * @var bool $requestURI
38
-	 */
39
-	protected static $requestURI;
40
-
41
-	/**
42
-	 * Get the http method parameter.
43
-	 * 
44
-	 * @var bool $httpMethodParameterOverride
45
-	 */
46
-	protected static $httpMethodParameterOverride = false;
34
+    /**
35
+     * Holds the global active request instance.
36
+     *
37
+     * @var bool $requestURI
38
+     */
39
+    protected static $requestURI;
40
+
41
+    /**
42
+     * Get the http method parameter.
43
+     * 
44
+     * @var bool $httpMethodParameterOverride
45
+     */
46
+    protected static $httpMethodParameterOverride = false;
47 47
 
48 48
     /**
49
-	 * Create a new Syscodes HTTP request from server variables.
50
-	 * 
51
-	 * @return static
52
-	 */
53
-	public static function capture(): static
54
-	{
55
-		static::enabledHttpMethodParameterOverride();
49
+     * Create a new Syscodes HTTP request from server variables.
50
+     * 
51
+     * @return static
52
+     */
53
+    public static function capture(): static
54
+    {
55
+        static::enabledHttpMethodParameterOverride();
56 56
 		
57
-		return static::createFromRequest(static::createFromRequestGlobals());
58
-	}
57
+        return static::createFromRequest(static::createFromRequestGlobals());
58
+    }
59 59
 
60
-	/**
60
+    /**
61 61
      * Enables support for the _method request parameter to determine the intended HTTP method.
62 62
      * 
63 63
      * @return void
@@ -67,101 +67,101 @@  discard block
 block discarded – undo
67 67
         self::$httpMethodParameterOverride = true;
68 68
     }
69 69
 	
70
-	/**
71
-	 * Checks whether support for the _method request parameter is enabled.
72
-	 * 
73
-	 * @return bool
74
-	 */
75
-	public static function getHttpMethodParameterOverride(): bool
76
-	{
77
-		return self::$httpMethodParameterOverride;
78
-	}
79
-
80
-	/**
81
-	 * Creates an Syscodes request from of the Request class instance.
82
-	 * 
83
-	 * @param  \Syscodes\Components\Http\Request  $request
84
-	 * 
85
-	 * @return static
86
-	 */
87
-	public static function createFromRequest($request): static
88
-	{
89
-		$newRequest = (new static)->duplicate(
90
-			$request->query->all(), $request->request->all(), $request->attributes->all(),
91
-			$request->cookies->all(), $request->files->all(), $request->server->all()
92
-		);
70
+    /**
71
+     * Checks whether support for the _method request parameter is enabled.
72
+     * 
73
+     * @return bool
74
+     */
75
+    public static function getHttpMethodParameterOverride(): bool
76
+    {
77
+        return self::$httpMethodParameterOverride;
78
+    }
79
+
80
+    /**
81
+     * Creates an Syscodes request from of the Request class instance.
82
+     * 
83
+     * @param  \Syscodes\Components\Http\Request  $request
84
+     * 
85
+     * @return static
86
+     */
87
+    public static function createFromRequest($request): static
88
+    {
89
+        $newRequest = (new static)->duplicate(
90
+            $request->query->all(), $request->request->all(), $request->attributes->all(),
91
+            $request->cookies->all(), $request->files->all(), $request->server->all()
92
+        );
93 93
 		
94
-		$newRequest->headers->replace($request->headers->all());
94
+        $newRequest->headers->replace($request->headers->all());
95 95
 		
96
-		$newRequest->content = $request->content;
96
+        $newRequest->content = $request->content;
97 97
 		
98
-		if ($newRequest->isJson()) {
99
-			$newRequest->request = $newRequest->json();
100
-		}
98
+        if ($newRequest->isJson()) {
99
+            $newRequest->request = $newRequest->json();
100
+        }
101 101
 		
102
-		return $newRequest;
103
-	}
104
-
105
-	/**
106
-	 * Creates a new request with value from PHP's super global.
107
-	 * 
108
-	 * @return static
109
-	 */
110
-	public static function createFromRequestGlobals(): static
111
-	{
112
-		$request = static::createFromRequestFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
113
-
114
-		if (Str::startsWith($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
115
-		    && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])) {
116
-			parse_str($request->getContent(), $data);
117
-			$request->request = new Inputs($data);
118
-		}
119
-
120
-		return $request;
121
-	}
122
-
123
-	/**
124
-	 * Creates a new request from a factory.
125
-	 * 
126
-	 * @param  array  $query
127
-	 * @param  array  $request
128
-	 * @param  array  $attributes
129
-	 * @param  array  $cookies
130
-	 * @param  array  $files
131
-	 * @param  array  $server
132
-	 * 
133
-	 * @return static
134
-	 */
135
-	private static function createFromRequestFactory(
136
-		array $query = [], 
137
-		array $request = [],
138
-		array $attributes = [] ,
139
-		array $cookies = [], 
140
-		array $files = [], 
141
-		array $server = []
142
-	): static {
143
-		if (self::$requestURI) {
144
-			$request = (self::$requestURI)($query, $request, [], $cookies, $files, $server);
145
-
146
-			if ( ! $request instanceof self) {
147
-				throw new LogicException('The Request active must return an instance of Syscodes\Components\Http\Request');
148
-			}
149
-
150
-			return $request;
151
-		}
152
-
153
-		return new static($query, $request, $attributes, $cookies, $files, $server);
154
-	}
155
-
156
-	/**
157
-	 * Returns the factory request currently being used.
158
-	 *
159
-	 * @param  \Syscodes\Components\Http\Request|callable|null  $request  
160
-	 *
161
-	 * @return void
162
-	 */
163
-	public static function setFactory(?callable $request): void
164
-	{
165
-		self::$requestURI = $request;
166
-	}
102
+        return $newRequest;
103
+    }
104
+
105
+    /**
106
+     * Creates a new request with value from PHP's super global.
107
+     * 
108
+     * @return static
109
+     */
110
+    public static function createFromRequestGlobals(): static
111
+    {
112
+        $request = static::createFromRequestFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
113
+
114
+        if (Str::startsWith($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
115
+            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])) {
116
+            parse_str($request->getContent(), $data);
117
+            $request->request = new Inputs($data);
118
+        }
119
+
120
+        return $request;
121
+    }
122
+
123
+    /**
124
+     * Creates a new request from a factory.
125
+     * 
126
+     * @param  array  $query
127
+     * @param  array  $request
128
+     * @param  array  $attributes
129
+     * @param  array  $cookies
130
+     * @param  array  $files
131
+     * @param  array  $server
132
+     * 
133
+     * @return static
134
+     */
135
+    private static function createFromRequestFactory(
136
+        array $query = [], 
137
+        array $request = [],
138
+        array $attributes = [] ,
139
+        array $cookies = [], 
140
+        array $files = [], 
141
+        array $server = []
142
+    ): static {
143
+        if (self::$requestURI) {
144
+            $request = (self::$requestURI)($query, $request, [], $cookies, $files, $server);
145
+
146
+            if ( ! $request instanceof self) {
147
+                throw new LogicException('The Request active must return an instance of Syscodes\Components\Http\Request');
148
+            }
149
+
150
+            return $request;
151
+        }
152
+
153
+        return new static($query, $request, $attributes, $cookies, $files, $server);
154
+    }
155
+
156
+    /**
157
+     * Returns the factory request currently being used.
158
+     *
159
+     * @param  \Syscodes\Components\Http\Request|callable|null  $request  
160
+     *
161
+     * @return void
162
+     */
163
+    public static function setFactory(?callable $request): void
164
+    {
165
+        self::$requestURI = $request;
166
+    }
167 167
 }
168 168
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	private static function createFromRequestFactory(
136 136
 		array $query = [], 
137 137
 		array $request = [],
138
-		array $attributes = [] ,
138
+		array $attributes = [],
139 139
 		array $cookies = [], 
140 140
 		array $files = [], 
141 141
 		array $server = []
Please login to merge, or discard this patch.
src/components/Http/Resources/HttpResponse.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      * 
50 50
      * @var \Syscodes\Components\Http\ResponseHeaders $headers
51 51
      */
52
-	public $headers;
52
+    public $headers;
53 53
 
54 54
     /**
55 55
      * The HTTP protocol version.
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.