Passed
Push — 0.7.0 ( a860c5...e442b6 )
by Alexander
03:31 queued 12s
created
src/components/Contracts/Routing/Routable.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -31,94 +31,94 @@
 block discarded – undo
31 31
  */
32 32
 interface Routable
33 33
 {
34
-	/**
35
-	 * Add a route for all posible methods.
36
-	 *
37
-	 * @param  string  $route
38
-	 * @param  \Closure|array|string  $action
39
-	 *
40
-	 * @return void
41
-	 */
42
-	public function any($route, $action);
34
+    /**
35
+     * Add a route for all posible methods.
36
+     *
37
+     * @param  string  $route
38
+     * @param  \Closure|array|string  $action
39
+     *
40
+     * @return void
41
+     */
42
+    public function any($route, $action);
43 43
 
44
-	/**
45
-	 * Add a route with delete method.
46
-	 *
47
-	 * @param  string  $route
48
-	 * @param  \Closure|array|string  $action
49
-	 *
50
-	 * @return void
51
-	 */
52
-	public function delete($route, $action);
44
+    /**
45
+     * Add a route with delete method.
46
+     *
47
+     * @param  string  $route
48
+     * @param  \Closure|array|string  $action
49
+     *
50
+     * @return void
51
+     */
52
+    public function delete($route, $action);
53 53
 
54
-	/**
55
-	 * Add a route with get method.
56
-	 * 
57
-	 * @param  string  $route
58
-	 * @param  \Closure|array|string  $action
59
-	 *
60
-	 * @return void
61
-	 */
62
-	public function get($route, $action);
54
+    /**
55
+     * Add a route with get method.
56
+     * 
57
+     * @param  string  $route
58
+     * @param  \Closure|array|string  $action
59
+     *
60
+     * @return void
61
+     */
62
+    public function get($route, $action);
63 63
 
64
-	/**
65
-	 * Add a route with head method.
66
-	 *
67
-	 * @param  string  $route
68
-	 * @param  \Closure|array|string  $action
69
-	 *
70
-	 * @return void
71
-	 */
72
-	public function head($route, $action);
64
+    /**
65
+     * Add a route with head method.
66
+     *
67
+     * @param  string  $route
68
+     * @param  \Closure|array|string  $action
69
+     *
70
+     * @return void
71
+     */
72
+    public function head($route, $action);
73 73
 
74
-	/**
75
-	 * Add a route with options method
76
-	 *
77
-	 * @param  string  $route
78
-	 * @param  \Closure|array|string  $action
79
-	 *
80
-	 * @return void
81
-	 */
82
-	public function options($route, $action);
74
+    /**
75
+     * Add a route with options method
76
+     *
77
+     * @param  string  $route
78
+     * @param  \Closure|array|string  $action
79
+     *
80
+     * @return void
81
+     */
82
+    public function options($route, $action);
83 83
 
84
-	/**
85
-	 * Add a route with patch method.
86
-	 *
87
-	 * @param  string  $route
88
-	 * @param  \Closure|array|string  $action
89
-	 *
90
-	 * @return void
91
-	 */
92
-	public function patch($route, $action);
84
+    /**
85
+     * Add a route with patch method.
86
+     *
87
+     * @param  string  $route
88
+     * @param  \Closure|array|string  $action
89
+     *
90
+     * @return void
91
+     */
92
+    public function patch($route, $action);
93 93
 
94
-	/**
95
-	 * Add a route with post method.
96
-	 *
97
-	 * @param  string  $route
98
-	 * @param  \Closure|array|string  $action
99
-	 *
100
-	 * @return void
101
-	 */
102
-	public function post($route, $action);
94
+    /**
95
+     * Add a route with post method.
96
+     *
97
+     * @param  string  $route
98
+     * @param  \Closure|array|string  $action
99
+     *
100
+     * @return void
101
+     */
102
+    public function post($route, $action);
103 103
 
104
-	/**
105
-	 * Add a route with put method.
106
-	 *
107
-	 * @param  string  $route
108
-	 * @param  \Closure|array|string  $action
109
-	 *
110
-	 * @return void
111
-	 */
112
-	public function put($route, $action);
104
+    /**
105
+     * Add a route with put method.
106
+     *
107
+     * @param  string  $route
108
+     * @param  \Closure|array|string  $action
109
+     *
110
+     * @return void
111
+     */
112
+    public function put($route, $action);
113 113
 
114
-	/**
115
-	 * Group a series of routes under a single URL segment. This is handy
116
-	 * for grouping items into an admin area.
117
-	 * 
118
-	 * @param  array  $attributes
119
-	 * @param  \Closure|string  $callback
120
-	 *
121
-	 * @return void
122
-	 */
123
-	public function group(array $attributes, $parameters);
114
+    /**
115
+     * Group a series of routes under a single URL segment. This is handy
116
+     * for grouping items into an admin area.
117
+     * 
118
+     * @param  array  $attributes
119
+     * @param  \Closure|string  $callback
120
+     *
121
+     * @return void
122
+     */
123
+    public function group(array $attributes, $parameters);
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Contracts/Console/Application.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
30 30
  */
31 31
 interface Application
32 32
 {
33
-	/**
34
-	 * Runs the current command discovered on the CLI.
35
-	 * 
36
-	 * @return void
37
-	 */	
38
-	public function run();
33
+    /**
34
+     * Runs the current command discovered on the CLI.
35
+     * 
36
+     * @return void
37
+     */	
38
+    public function run();
39 39
 	
40
-	/**
41
-	 * Displays basic information about the Console.
42
-	 * 
43
-	 * @return void
44
-	 * 
45
-	 * @uses   Version::RELEASE
46
-	 */ 
47
-	public function showHeader(); 
40
+    /**
41
+     * Displays basic information about the Console.
42
+     * 
43
+     * @return void
44
+     * 
45
+     * @uses   Version::RELEASE
46
+     */ 
47
+    public function showHeader(); 
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Contracts/View/Factory.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@
 block discarded – undo
31 31
 interface Factory
32 32
 {
33 33
     /**
34
-	 * Check existance view file.
35
-	 * 
36
-	 * @param  string  $view
37
-	 *
38
-	 * @return bool
39
-	 */
34
+     * Check existance view file.
35
+     * 
36
+     * @param  string  $view
37
+     *
38
+     * @return bool
39
+     */
40 40
     public function viewExists($view);
41 41
 
42 42
     /**
Please login to merge, or discard this patch.
src/components/Contracts/View/View.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -32,29 +32,29 @@
 block discarded – undo
32 32
  */
33 33
 interface View extends Renderable
34 34
 {
35
-	/**
36
-	 * Add a piece of data to the view.
37
-	 * 
38
-	 * @example  $view->assign($content, $data);
39
-	 * 
40
-	 * @param  string|array  $key
41
-	 * @param  mixed  $value
42
-	 * 
43
-	 * @return $this
44
-	 */
45
-	public function assign($key, $value = null);
35
+    /**
36
+     * Add a piece of data to the view.
37
+     * 
38
+     * @example  $view->assign($content, $data);
39
+     * 
40
+     * @param  string|array  $key
41
+     * @param  mixed  $value
42
+     * 
43
+     * @return $this
44
+     */
45
+    public function assign($key, $value = null);
46 46
 	
47
-	/**
48
-	 * Assigns a value by reference. The benefit of binding is that values can be altered
49
-	 * without re-setting them. It is also possible to bind variables before they have values.
50
-	 * Assigned values will be available as a variable within the view file:
51
-	 * 
52
-	 * @example  $view->bind('ref', $bar);
53
-	 * 
54
-	 * @param  string  $key  Variable name
55
-	 * @param  mixed  $value  Referenced variable
56
-	 * 
57
-	 * @return $this
58
-	 */
59
-	public function bind($key, & $value);
47
+    /**
48
+     * Assigns a value by reference. The benefit of binding is that values can be altered
49
+     * without re-setting them. It is also possible to bind variables before they have values.
50
+     * Assigned values will be available as a variable within the view file:
51
+     * 
52
+     * @example  $view->bind('ref', $bar);
53
+     * 
54
+     * @param  string  $key  Variable name
55
+     * @param  mixed  $value  Referenced variable
56
+     * 
57
+     * @return $this
58
+     */
59
+    public function bind($key, & $value);
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Contracts/Debug/Handler.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -32,88 +32,88 @@
 block discarded – undo
32 32
  */
33 33
 interface Handler
34 34
 {
35
-	const ERROR_HANDLER     = "HandleError";
36
-	const EXCEPTION_HANDLER = "handleException";
37
-	const SHUTDOWN_HANDLER  = "handleShutdown"; 
35
+    const ERROR_HANDLER     = "HandleError";
36
+    const EXCEPTION_HANDLER = "handleException";
37
+    const SHUTDOWN_HANDLER  = "handleShutdown"; 
38 38
 	
39
-	/**
40
-	 * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the 
41
-	 * error, display it if display_errors is on, and fire an event that allows custom actions 
42
-	 * to be taken at this point.
43
-	 *
44
-	 * @param  \Throwable  $exception
45
-	 *
46
-	 * @return string
47
-	 */
48
-	public function handleException(Throwable $exception);
39
+    /**
40
+     * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the 
41
+     * error, display it if display_errors is on, and fire an event that allows custom actions 
42
+     * to be taken at this point.
43
+     *
44
+     * @param  \Throwable  $exception
45
+     *
46
+     * @return string
47
+     */
48
+    public function handleException(Throwable $exception);
49 49
 	
50
-	/**
51
-	 * Pushes a handler to the end of the stack.
52
-	 * 
53
-	 * @param  string|callable  $handler
54
-	 * 
55
-	 * @return \Syscodes\Contracts\Debug\Handler
56
-	 */
57
-	public function pushHandler($handler);
50
+    /**
51
+     * Pushes a handler to the end of the stack.
52
+     * 
53
+     * @param  string|callable  $handler
54
+     * 
55
+     * @return \Syscodes\Contracts\Debug\Handler
56
+     */
57
+    public function pushHandler($handler);
58 58
 	
59
-	/**
60
-	 * Unregisters all handlers registered by this Debug instance.
61
-	 * 
62
-	 * @return void
63
-	 */
64
-	public function off();
59
+    /**
60
+     * Unregisters all handlers registered by this Debug instance.
61
+     * 
62
+     * @return void
63
+     */
64
+    public function off();
65 65
 	
66
-	/**
67
-	 * Registers this instance as an error handler.
68
-	 * 
69
-	 * @return void
70
-	 */
71
-	public function on();
66
+    /**
67
+     * Registers this instance as an error handler.
68
+     * 
69
+     * @return void
70
+     */
71
+    public function on();
72 72
 	
73
-	/**
74
-	 * Lenevor Exception push output directly to the client it the data  
75
-	 * if they are true, but if it is false, the output will be returned 
76
-	 * by exception.
77
-	 * 
78
-	 * @param  bool|int  $send
79
-	 *
80
-	 * @return bool
81
-	 */
82
-	public function writeToOutput($send = null);
73
+    /**
74
+     * Lenevor Exception push output directly to the client it the data  
75
+     * if they are true, but if it is false, the output will be returned 
76
+     * by exception.
77
+     * 
78
+     * @param  bool|int  $send
79
+     *
80
+     * @return bool
81
+     */
82
+    public function writeToOutput($send = null);
83 83
 	
84
-	/**
85
-	 * Error handler
86
-	 *
87
-	 * This will catch the php native error and treat it as a exception which will 
88
-	 * provide a full back trace on all errors.
89
-	 *
90
-	 * @param  int  $level
91
-	 * @param  string  $message
92
-	 * @param  string|null  $file
93
-	 * @param  int|null  $line
94
-	 *
95
-	 * @throws \ErrorException
96
-	 */
97
-	public function handleError(int $level, string $message, string $file = null, int $line = null);
84
+    /**
85
+     * Error handler
86
+     *
87
+     * This will catch the php native error and treat it as a exception which will 
88
+     * provide a full back trace on all errors.
89
+     *
90
+     * @param  int  $level
91
+     * @param  string  $message
92
+     * @param  string|null  $file
93
+     * @param  int|null  $line
94
+     *
95
+     * @throws \ErrorException
96
+     */
97
+    public function handleError(int $level, string $message, string $file = null, int $line = null);
98 98
 	
99
-	/**
100
-	 * Lenevor Exception will by default send HTTP code 500, but you may wish
101
-	 * to use 502, 503, or another 5xx family code.
102
-	 * 
103
-	 * @param  bool|int  $code
104
-	 * 
105
-	 * @return int|false
106
-	 * 
107
-	 * @throws \InvalidArgumentException
108
-	 */
109
-	public function sendHttpCode($code = null);
99
+    /**
100
+     * Lenevor Exception will by default send HTTP code 500, but you may wish
101
+     * to use 502, 503, or another 5xx family code.
102
+     * 
103
+     * @param  bool|int  $code
104
+     * 
105
+     * @return int|false
106
+     * 
107
+     * @throws \InvalidArgumentException
108
+     */
109
+    public function sendHttpCode($code = null);
110 110
 	
111
-	/**
112
-	 * This will catch errors that are generated at the shutdown level of execution.
113
-	 *
114
-	 * @return void
115
-	 *
116
-	 * @throws \ErrorException
117
-	 */
118
-	public function handleShutdown();
111
+    /**
112
+     * This will catch errors that are generated at the shutdown level of execution.
113
+     *
114
+     * @return void
115
+     *
116
+     * @throws \ErrorException
117
+     */
118
+    public function handleShutdown();
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Contracts/Config/Configure.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -30,54 +30,54 @@
 block discarded – undo
30 30
  */
31 31
 interface Configure
32 32
 {
33
-	/**
34
-	 * Determine if the given configuration value exists.
35
-	 * 
36
-	 * @param  string  $key
37
-	 * 
38
-	 * @return bool
39
-	 */
40
-	public function has(string $key);
33
+    /**
34
+     * Determine if the given configuration value exists.
35
+     * 
36
+     * @param  string  $key
37
+     * 
38
+     * @return bool
39
+     */
40
+    public function has(string $key);
41 41
 
42
-	/**
43
-	 * Deletes a (dot notated) config item.
44
-	 * 
45
-	 * @param  string  $key  A (dot notated) config key
46
-	 * 
47
-	 * @return array|bool
48
-	 * 
49
-	 * @uses   \Syscodes\Support\Arr
50
-	 */	
51
-	public function erase(string $key);
42
+    /**
43
+     * Deletes a (dot notated) config item.
44
+     * 
45
+     * @param  string  $key  A (dot notated) config key
46
+     * 
47
+     * @return array|bool
48
+     * 
49
+     * @uses   \Syscodes\Support\Arr
50
+     */	
51
+    public function erase(string $key);
52 52
 
53
-	/**
54
-	 * Returns a (dot notated) config setting.
55
-	 *
56
-	 * @param  string  $key  The dot-notated key or array of keys
57
-	 * @param  mixed  $default  The default value
58
-	 *
59
-	 * @return mixed
60
-	 *
61
-	 * @uses    \Syscodes\Support\Arr
62
-	 */
63
-	public function get(string $key, $default = null);
53
+    /**
54
+     * Returns a (dot notated) config setting.
55
+     *
56
+     * @param  string  $key  The dot-notated key or array of keys
57
+     * @param  mixed  $default  The default value
58
+     *
59
+     * @return mixed
60
+     *
61
+     * @uses    \Syscodes\Support\Arr
62
+     */
63
+    public function get(string $key, $default = null);
64 64
 	
65
-	/**
66
-	 * Sets a value in the config array.
67
-	 *
68
-	 * @param  string  $key  The dot-notated key or array of keys
69
-	 * @param  mixed  $value  The default value
70
-	 *
71
-	 * @return mixed
72
-	 *
73
-	 * @uses  \Syscodes\Support\Arr
74
-	 */
75
-	public function set(string $key, $value);
65
+    /**
66
+     * Sets a value in the config array.
67
+     *
68
+     * @param  string  $key  The dot-notated key or array of keys
69
+     * @param  mixed  $value  The default value
70
+     *
71
+     * @return mixed
72
+     *
73
+     * @uses  \Syscodes\Support\Arr
74
+     */
75
+    public function set(string $key, $value);
76 76
 
77
-	/**
78
-	 * Get all of the configuration items for the application.
79
-	 * 
80
-	 * @return array
81
-	 */
82
-	public function all();
77
+    /**
78
+     * Get all of the configuration items for the application.
79
+     * 
80
+     * @return array
81
+     */
82
+    public function all();
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Contracts/Container/Container.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function extend($id, Closure $closure);
68 68
 
69
-     /**
70
-     * Marks a callable as being a factory service.
71
-     * 
72
-     * @param  string  $id
73
-     * 
74
-     * @return \Closure
75
-     */
69
+        /**
70
+         * Marks a callable as being a factory service.
71
+         * 
72
+         * @param  string  $id
73
+         * 
74
+         * @return \Closure
75
+         */
76 76
     public function factory($id);
77 77
 
78 78
     /**
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function getBindings();
84 84
 
85
-     /**
86
-     * Register an existing instance as singleton in the container.
87
-     *
88
-     * @param  string  $id
89
-     * @param  mixed  $instance
90
-     * 
91
-     * @return mixed
92
-     */
85
+        /**
86
+         * Register an existing instance as singleton in the container.
87
+         *
88
+         * @param  string  $id
89
+         * @param  mixed  $instance
90
+         * 
91
+         * @return mixed
92
+         */
93 93
     public function instance($id, $instance);
94 94
 
95 95
     /**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function set($id, string $value);
123 123
 
124
-     /**
125
-     * Register a singleton binding in the container.
126
-     * 
127
-     * @param  string  $id
128
-     * @param  \Closure|string|null  $value
129
-     * 
130
-     * @return void
131
-     */
124
+        /**
125
+         * Register a singleton binding in the container.
126
+         * 
127
+         * @param  string  $id
128
+         * @param  \Closure|string|null  $value
129
+         * 
130
+         * @return void
131
+         */
132 132
     public function singleton($id, $value = null);
133 133
 }
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Http/Request.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -875,7 +875,7 @@
 block discarded – undo
875 875
 
876 876
 		foreach ($this->cookies as $key => $value)
877 877
 		{
878
-			$cookies[]= "{$key} = {$value}";
878
+			$cookies[] = "{$key} = {$value}";
879 879
 		}
880 880
 
881 881
 		if ( ! empty($cookies))
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -860,8 +860,7 @@
 block discarded – undo
860 860
 		try
861 861
 		{
862 862
 			$content = $this->getContent();
863
-		}
864
-		catch (LogicException $e)
863
+		} catch (LogicException $e)
865 864
 		{
866 865
 			if (PHP_VERSION_ID > 70400)
867 866
 			{
Please login to merge, or discard this patch.
Indentation   +850 added lines, -850 removed lines patch added patch discarded remove patch
@@ -40,868 +40,868 @@
 block discarded – undo
40 40
  */
41 41
 class Request
42 42
 {
43
-	/**
44
-	 * Holds the global active request instance.
45
-	 *
46
-	 * @var bool $requestURI
47
-	 */
48
-	protected static $requestURI;
49
-
50
-	/**
51
-	 * The base URL.
52
-	 * 
53
-	 * @var string $baseUrl
54
-	 */
55
-	protected $baseUrl;
56
-
57
-	/**
58
-	 * Gets cookies ($_COOKIE).
59
-	 * 
60
-	 * @var string $cookies
61
-	 */
62
-	public $cookies;
63
-
64
-	/**
65
-	 * Gets the string with format JSON.
66
-	 * 
67
-	 * @var string|resource|null $content
68
-	 */
69
-	protected $content;
70
-
71
-	/**
72
-	 * The default Locale this request.
73
-	 * 
74
-	 * @var string $defaultLocale
75
-	 */
76
-	protected $defaultLocale = 'en';
43
+    /**
44
+     * Holds the global active request instance.
45
+     *
46
+     * @var bool $requestURI
47
+     */
48
+    protected static $requestURI;
49
+
50
+    /**
51
+     * The base URL.
52
+     * 
53
+     * @var string $baseUrl
54
+     */
55
+    protected $baseUrl;
56
+
57
+    /**
58
+     * Gets cookies ($_COOKIE).
59
+     * 
60
+     * @var string $cookies
61
+     */
62
+    public $cookies;
63
+
64
+    /**
65
+     * Gets the string with format JSON.
66
+     * 
67
+     * @var string|resource|null $content
68
+     */
69
+    protected $content;
70
+
71
+    /**
72
+     * The default Locale this request.
73
+     * 
74
+     * @var string $defaultLocale
75
+     */
76
+    protected $defaultLocale = 'en';
77 77
 	
78
-	/**
79
-	 * Gets files request ($_FILES).
80
-	 * 
81
-	 * @var string $files
82
-	 */
83
-	public $files;
84
-
85
-	/**
86
-	 * The detected uri and server variables.
87
-	 * 
88
-	 * @var string $http
89
-	 */
90
-	protected $http;
91
-
92
-	/**
93
-	 * The decoded JSON content for the request.
94
-	 * 
95
-	 * @var \Syscodes\Http\Contributors\Parameters|null $json
96
-	 */
97
-	protected $json;
98
-
99
-	/**
100
-	 * The current language of the application.
101
-	 * 
102
-	 * @var string $languages
103
-	 */
104
-	protected $languages;
78
+    /**
79
+     * Gets files request ($_FILES).
80
+     * 
81
+     * @var string $files
82
+     */
83
+    public $files;
84
+
85
+    /**
86
+     * The detected uri and server variables.
87
+     * 
88
+     * @var string $http
89
+     */
90
+    protected $http;
91
+
92
+    /**
93
+     * The decoded JSON content for the request.
94
+     * 
95
+     * @var \Syscodes\Http\Contributors\Parameters|null $json
96
+     */
97
+    protected $json;
98
+
99
+    /**
100
+     * The current language of the application.
101
+     * 
102
+     * @var string $languages
103
+     */
104
+    protected $languages;
105 105
 	
106
-	/** 
107
-	 * The method name.
108
-	 * 
109
-	 * @var string $method
110
-	 */
111
-	protected $method;
112
-
113
-	/**
114
-	 * The path info of URL.
115
-	 * 
116
-	 * @var string $pathInfo
117
-	 */
118
-	protected $pathInfo;
119
-
120
-	/**
121
-	 * Request body parameters ($_POST).
122
-	 * 
123
-	 * @var \Syscodes\Http\Contributors\Parameters $request
124
-	 */
125
-	public $request;
126
-
127
-	/**
128
-	 * Get request URI.
129
-	 * 
130
-	 * @var string $requestToURI
131
-	 */
132
-	protected $requestToURI;
133
-
134
-	/**
135
-	 * The detected uri and server variables ($_FILES).
136
-	 * 
137
-	 * @var array $server
138
-	 */
139
-	public $server = [];
140
-
141
-	/** 
142
-	 * List of routes uri.
143
-	 *
144
-	 * @var string|array $uri 
145
-	 */
146
-	public $uri;
147
-
148
-	/**
149
-	 * Stores the valid locale codes.
150
-	 * 
151
-	 * @var array $validLocales
152
-	 */
153
-	protected $validLocales = [];
154
-
155
-	/**
156
-	 * Constructor: Create new the Request class.
157
-	 * 
158
-	 * @param  array  $request
159
-	 * @param  array  $cookies
160
-	 * @param  array  $files
161
-	 * @param  array  $server
162
-	 * @param  string|resource|null $content  
163
-	 * 
164
-	 * @return void
165
-	 */
166
-	public function __construct(array $request = [], array $cookies = [], array $files = [], array $server = [], $content = null)
167
-	{
168
-		static::$requestURI = $this;
106
+    /** 
107
+     * The method name.
108
+     * 
109
+     * @var string $method
110
+     */
111
+    protected $method;
112
+
113
+    /**
114
+     * The path info of URL.
115
+     * 
116
+     * @var string $pathInfo
117
+     */
118
+    protected $pathInfo;
119
+
120
+    /**
121
+     * Request body parameters ($_POST).
122
+     * 
123
+     * @var \Syscodes\Http\Contributors\Parameters $request
124
+     */
125
+    public $request;
126
+
127
+    /**
128
+     * Get request URI.
129
+     * 
130
+     * @var string $requestToURI
131
+     */
132
+    protected $requestToURI;
133
+
134
+    /**
135
+     * The detected uri and server variables ($_FILES).
136
+     * 
137
+     * @var array $server
138
+     */
139
+    public $server = [];
140
+
141
+    /** 
142
+     * List of routes uri.
143
+     *
144
+     * @var string|array $uri 
145
+     */
146
+    public $uri;
147
+
148
+    /**
149
+     * Stores the valid locale codes.
150
+     * 
151
+     * @var array $validLocales
152
+     */
153
+    protected $validLocales = [];
154
+
155
+    /**
156
+     * Constructor: Create new the Request class.
157
+     * 
158
+     * @param  array  $request
159
+     * @param  array  $cookies
160
+     * @param  array  $files
161
+     * @param  array  $server
162
+     * @param  string|resource|null $content  
163
+     * 
164
+     * @return void
165
+     */
166
+    public function __construct(array $request = [], array $cookies = [], array $files = [], array $server = [], $content = null)
167
+    {
168
+        static::$requestURI = $this;
169 169
 		
170
-		$this->initialize($request, $cookies, $files, $server, $content);
171
-
172
-		$this->detectURI(config('app.uriProtocol'), config('app.baseUrl'));
173
-
174
-		$this->detectLocale();
175
-	}
176
-
177
-	/**
178
-	 * Sets the parameters for this request.
179
-	 * 
180
-	 * @param  array  $request
181
-	 * @param  array  $cookies
182
-	 * @param  array  $files
183
-	 * @param  array  $server
184
-	 * 
185
-	 * @return void
186
-	 */
187
-	public function initialize(array $request = [], array $cookies = [], array $files = [], array $server = [], $content = null)
188
-	{
189
-		$this->request      = new Parameters($request);
190
-		$this->cookies      = new Inputs($cookies);
191
-		$this->files        = new Files($files);
192
-		$this->server       = new Server($server);
193
-		$this->headers      = new Headers($this->server->all());
194
-
195
-		$this->uri          = new URI;
196
-		$this->http         = new Http;
197
-		$this->method       = null;
198
-		$this->baseUrl      = null;
199
-		$this->content      = $content;
200
-		$this->pathInfo     = null;
201
-		$this->languages    = null;
202
-		$this->validLocales = config('app.supportedLocales');
203
-	}
204
-
205
-	/**
206
-	 * Create a new Syscodes HTTP request from server variables.
207
-	 * 
208
-	 * @return static
209
-	 */
210
-	public static function capture()
211
-	{
212
-		return static::createFromRequest(static::createFromRequestGlobals());
213
-	}
214
-
215
-	/**
216
-	 * Creates an Syscodes request from of the Request class instance.
217
-	 * 
218
-	 * @param  \Syscodes\Http\Request  $request
219
-	 * 
220
-	 * @return static
221
-	 */
222
-	public static function createFromRequest($request)
223
-	{
224
-		$newRequest = (new static)->duplicate(
225
-			$request->request->all(), $request->cookies->all(), 
226
-			$request->files->all(), $request->server->all()
227
-		);
228
-
229
-		$newRequest->content = $request->content;
230
-
231
-		return $newRequest;
232
-	}
233
-
234
-	/**
235
-	 * Creates a new request with value from PHP's super global.
236
-	 * 
237
-	 * @return static
238
-	 */
239
-	public static function createFromRequestGlobals()
240
-	{
241
-		$request = static::createFromRequestFactory($_POST, $_COOKIE, $_FILES, $_SERVER);
242
-
243
-		return $request;
244
-	}
245
-
246
-	/**
247
-	 * Creates a new request from a factory.
248
-	 * 
249
-	 * @param  array  $request
250
-	 * @param  array  $cookies
251
-	 * @param  array  $files
252
-	 * @param  array  $server
253
-	 * 
254
-	 * @return static
255
-	 */
256
-	protected static function createFromRequestFactory(array $request = [], array $cookies = [], array $files = [], array $server = [])
257
-	{
258
-		if (self::$requestURI) {
259
-			$request = (self::$requestURI)($request, $cookies, $files, $server);
260
-
261
-			if ( ! $request instanceof self) {
262
-				throw new LogicException('The Request active must return an instance of Syscodes\Http\Request');
263
-			}
264
-
265
-			return $request;
266
-		}
267
-
268
-		return new static($request, $cookies, $files, $server);
269
-	}
270
-
271
-	/**
272
-	 * Clones a request and overrides some of its parameters.
273
-	 * 
274
-	 * @param  array  $request
275
-	 * @param  array  $cookies
276
-	 * @param  array  $files
277
-	 * @param  array  $server
278
-	 * 
279
-	 * @return static
280
-	 */
281
-	public function duplicate(array $request = [], array $cookies = [], array $files = [], array $server = [])
282
-	{
283
-		$duplicate = clone $this;
284
-
285
-		if (null !== $request) {
286
-			$duplicate->request = new Parameters($request);
287
-		}
288
-
289
-		if (null !== $cookies) {
290
-			$duplicate->cookies = new Inputs($cookies);
291
-		}
292
-
293
-		if (null !== $files) {
294
-			$duplicate->files = new Files($files);
295
-		}
296
-
297
-		if (null !== $server) {
298
-			$duplicate->server  = new Server($server);
299
-			$duplicate->headers = new Headers($duplicate->server->all());
300
-		}
301
-
302
-		$duplicate->uri          = new URI;
303
-		$duplicate->http         = new Http;
304
-		$duplicate->locale       = null;
305
-		$duplicate->method       = null;
306
-		$duplicate->baseUrl      = null;
307
-		$duplicate->pathInfo     = null;
308
-		$duplicate->validLocales = config('app.supportedLocales');
309
-
310
-		return $duplicate;		
311
-	}
312
-
313
-	/**
314
-	 * Returns the active request currently being used.
315
-	 *
316
-	 * @param  \Syscodes\Http\Request|bool|null  $request  Overwrite current request 
317
-	 *                                                     before returning, false prevents 
318
-	 *                                                     overwrite
319
-	 *
320
-	 * @return \Syscodes\Http\Request
321
-	 */
322
-	public static function active($request = false)
323
-	{
324
-		if ($request !== false) {
325
-			static::$requestURI = $request;
326
-		}
327
-
328
-		return static::$requestURI;
329
-	}
330
-
331
-	/**
332
-	 * Returns the desired segment, or $default if it does not exist.
333
-	 *
334
-	 * @param  int  $index  The segment number (1-based index)
335
-	 * @param  mixed  $default  Default value to return
336
-	 *
337
-	 * @return  string
338
-	 */
339
-	public function segment($index, $default = null)
340
-	{
341
-		if ($request = static::active()) {
342
-			return $request->uri->getSegment($index, $default);
343
-		}
344
-
345
-		return null;
346
-	}
347
-
348
-	/**
349
-	 * Returns all segments in an array. For total of segments
350
-	 * used the function PHP count().
351
-	 *
352
-	 * @return array
353
-	 */
354
-	public function segments()
355
-	{
356
-		if ($request = static::active()) {
357
-			return $request->uri->getSegments();
358
-		}
359
-
360
-		return null;
361
-	}
362
-
363
-	/**
364
-	 * Returns the total number of segment.
365
-	 *
366
-	 * @return int|null  
367
-	 */
368
-	public function totalSegments()
369
-	{
370
-		if ($request = static::active()) {
371
-			return $request->uri->getTotalSegments();
372
-		}
373
-
374
-		return null;
375
-	}
376
-
377
-	/**
378
-	 * Detects and returns the current URI based on a number of different server variables.
379
-	 * 
380
-	 * @param  string  $protocol
381
-	 * @param  string  $baseUrl
382
-	 * 
383
-	 * @return string
384
-	 */
385
-	protected function detectURI(string $protocol, string $baseUrl)
386
-	{
387
-		$this->uri->setPath($this->http->detectPath($protocol));
388
-
389
-		$baseUrl = ! empty($baseUrl) ? rtrim($baseUrl, '/ ').'/' : $baseUrl;
390
-
391
-		if ( ! empty($baseUrl)) {
392
-			$this->uri->setScheme(parse_url($baseUrl, PHP_URL_SCHEME));
393
-			$this->uri->setHost(parse_url($baseUrl, PHP_URL_HOST));
394
-			$this->uri->setPort(parse_url($baseUrl, PHP_URL_PORT));
395
-		} else {
396
-			if ( ! $this->http->isCli()) {
397
-				exit('You have an empty or invalid base URL. The baseURL value must be set in config/app.php, or through the .env file.');
398
-			}
399
-		}
400
-	}
401
-
402
-	/**
403
-	 * Handles setting up the locale, auto-detecting of language.
404
-	 * 
405
-	 * @return void
406
-	 */
407
-	public function detectLocale()
408
-	{
409
-		$this->languages = $this->defaultLocale = config('app.locale');
410
-
411
-		$this->setLocale($this->validLocales);
412
-	}
413
-
414
-	/**
415
-	 * Returns the default locale as set.
416
-	 * 
417
-	 * @return string
418
-	 */
419
-	public function getDefaultLocale()
420
-	{
421
-		return $this->defaultLocale;
422
-	}
423
-
424
-	/**
425
-	 * Gets the current locale, with a fallback to the default.
426
-	 * 
427
-	 * @return string 
428
-	 */
429
-	public function getLocale()
430
-	{
431
-		return $this->languages ?: $this->defaultLocale;
432
-	}
433
-
434
-	/**
435
-	 * Sets the locale string for this request.
436
-	 * 
437
-	 * @param  string  $locale
438
-	 * 
439
-	 * @return \Syscodes\Http\Request
440
-	 */
441
-	public function setLocale($locale)
442
-	{
443
-		if ( ! in_array($locale, $this->validLocales)) {
444
-			$locale = $this->defaultLocale;
445
-		}
170
+        $this->initialize($request, $cookies, $files, $server, $content);
171
+
172
+        $this->detectURI(config('app.uriProtocol'), config('app.baseUrl'));
173
+
174
+        $this->detectLocale();
175
+    }
176
+
177
+    /**
178
+     * Sets the parameters for this request.
179
+     * 
180
+     * @param  array  $request
181
+     * @param  array  $cookies
182
+     * @param  array  $files
183
+     * @param  array  $server
184
+     * 
185
+     * @return void
186
+     */
187
+    public function initialize(array $request = [], array $cookies = [], array $files = [], array $server = [], $content = null)
188
+    {
189
+        $this->request      = new Parameters($request);
190
+        $this->cookies      = new Inputs($cookies);
191
+        $this->files        = new Files($files);
192
+        $this->server       = new Server($server);
193
+        $this->headers      = new Headers($this->server->all());
194
+
195
+        $this->uri          = new URI;
196
+        $this->http         = new Http;
197
+        $this->method       = null;
198
+        $this->baseUrl      = null;
199
+        $this->content      = $content;
200
+        $this->pathInfo     = null;
201
+        $this->languages    = null;
202
+        $this->validLocales = config('app.supportedLocales');
203
+    }
204
+
205
+    /**
206
+     * Create a new Syscodes HTTP request from server variables.
207
+     * 
208
+     * @return static
209
+     */
210
+    public static function capture()
211
+    {
212
+        return static::createFromRequest(static::createFromRequestGlobals());
213
+    }
214
+
215
+    /**
216
+     * Creates an Syscodes request from of the Request class instance.
217
+     * 
218
+     * @param  \Syscodes\Http\Request  $request
219
+     * 
220
+     * @return static
221
+     */
222
+    public static function createFromRequest($request)
223
+    {
224
+        $newRequest = (new static)->duplicate(
225
+            $request->request->all(), $request->cookies->all(), 
226
+            $request->files->all(), $request->server->all()
227
+        );
228
+
229
+        $newRequest->content = $request->content;
230
+
231
+        return $newRequest;
232
+    }
233
+
234
+    /**
235
+     * Creates a new request with value from PHP's super global.
236
+     * 
237
+     * @return static
238
+     */
239
+    public static function createFromRequestGlobals()
240
+    {
241
+        $request = static::createFromRequestFactory($_POST, $_COOKIE, $_FILES, $_SERVER);
242
+
243
+        return $request;
244
+    }
245
+
246
+    /**
247
+     * Creates a new request from a factory.
248
+     * 
249
+     * @param  array  $request
250
+     * @param  array  $cookies
251
+     * @param  array  $files
252
+     * @param  array  $server
253
+     * 
254
+     * @return static
255
+     */
256
+    protected static function createFromRequestFactory(array $request = [], array $cookies = [], array $files = [], array $server = [])
257
+    {
258
+        if (self::$requestURI) {
259
+            $request = (self::$requestURI)($request, $cookies, $files, $server);
260
+
261
+            if ( ! $request instanceof self) {
262
+                throw new LogicException('The Request active must return an instance of Syscodes\Http\Request');
263
+            }
264
+
265
+            return $request;
266
+        }
267
+
268
+        return new static($request, $cookies, $files, $server);
269
+    }
270
+
271
+    /**
272
+     * Clones a request and overrides some of its parameters.
273
+     * 
274
+     * @param  array  $request
275
+     * @param  array  $cookies
276
+     * @param  array  $files
277
+     * @param  array  $server
278
+     * 
279
+     * @return static
280
+     */
281
+    public function duplicate(array $request = [], array $cookies = [], array $files = [], array $server = [])
282
+    {
283
+        $duplicate = clone $this;
284
+
285
+        if (null !== $request) {
286
+            $duplicate->request = new Parameters($request);
287
+        }
288
+
289
+        if (null !== $cookies) {
290
+            $duplicate->cookies = new Inputs($cookies);
291
+        }
292
+
293
+        if (null !== $files) {
294
+            $duplicate->files = new Files($files);
295
+        }
296
+
297
+        if (null !== $server) {
298
+            $duplicate->server  = new Server($server);
299
+            $duplicate->headers = new Headers($duplicate->server->all());
300
+        }
301
+
302
+        $duplicate->uri          = new URI;
303
+        $duplicate->http         = new Http;
304
+        $duplicate->locale       = null;
305
+        $duplicate->method       = null;
306
+        $duplicate->baseUrl      = null;
307
+        $duplicate->pathInfo     = null;
308
+        $duplicate->validLocales = config('app.supportedLocales');
309
+
310
+        return $duplicate;		
311
+    }
312
+
313
+    /**
314
+     * Returns the active request currently being used.
315
+     *
316
+     * @param  \Syscodes\Http\Request|bool|null  $request  Overwrite current request 
317
+     *                                                     before returning, false prevents 
318
+     *                                                     overwrite
319
+     *
320
+     * @return \Syscodes\Http\Request
321
+     */
322
+    public static function active($request = false)
323
+    {
324
+        if ($request !== false) {
325
+            static::$requestURI = $request;
326
+        }
327
+
328
+        return static::$requestURI;
329
+    }
330
+
331
+    /**
332
+     * Returns the desired segment, or $default if it does not exist.
333
+     *
334
+     * @param  int  $index  The segment number (1-based index)
335
+     * @param  mixed  $default  Default value to return
336
+     *
337
+     * @return  string
338
+     */
339
+    public function segment($index, $default = null)
340
+    {
341
+        if ($request = static::active()) {
342
+            return $request->uri->getSegment($index, $default);
343
+        }
344
+
345
+        return null;
346
+    }
347
+
348
+    /**
349
+     * Returns all segments in an array. For total of segments
350
+     * used the function PHP count().
351
+     *
352
+     * @return array
353
+     */
354
+    public function segments()
355
+    {
356
+        if ($request = static::active()) {
357
+            return $request->uri->getSegments();
358
+        }
359
+
360
+        return null;
361
+    }
362
+
363
+    /**
364
+     * Returns the total number of segment.
365
+     *
366
+     * @return int|null  
367
+     */
368
+    public function totalSegments()
369
+    {
370
+        if ($request = static::active()) {
371
+            return $request->uri->getTotalSegments();
372
+        }
373
+
374
+        return null;
375
+    }
376
+
377
+    /**
378
+     * Detects and returns the current URI based on a number of different server variables.
379
+     * 
380
+     * @param  string  $protocol
381
+     * @param  string  $baseUrl
382
+     * 
383
+     * @return string
384
+     */
385
+    protected function detectURI(string $protocol, string $baseUrl)
386
+    {
387
+        $this->uri->setPath($this->http->detectPath($protocol));
388
+
389
+        $baseUrl = ! empty($baseUrl) ? rtrim($baseUrl, '/ ').'/' : $baseUrl;
390
+
391
+        if ( ! empty($baseUrl)) {
392
+            $this->uri->setScheme(parse_url($baseUrl, PHP_URL_SCHEME));
393
+            $this->uri->setHost(parse_url($baseUrl, PHP_URL_HOST));
394
+            $this->uri->setPort(parse_url($baseUrl, PHP_URL_PORT));
395
+        } else {
396
+            if ( ! $this->http->isCli()) {
397
+                exit('You have an empty or invalid base URL. The baseURL value must be set in config/app.php, or through the .env file.');
398
+            }
399
+        }
400
+    }
401
+
402
+    /**
403
+     * Handles setting up the locale, auto-detecting of language.
404
+     * 
405
+     * @return void
406
+     */
407
+    public function detectLocale()
408
+    {
409
+        $this->languages = $this->defaultLocale = config('app.locale');
410
+
411
+        $this->setLocale($this->validLocales);
412
+    }
413
+
414
+    /**
415
+     * Returns the default locale as set.
416
+     * 
417
+     * @return string
418
+     */
419
+    public function getDefaultLocale()
420
+    {
421
+        return $this->defaultLocale;
422
+    }
423
+
424
+    /**
425
+     * Gets the current locale, with a fallback to the default.
426
+     * 
427
+     * @return string 
428
+     */
429
+    public function getLocale()
430
+    {
431
+        return $this->languages ?: $this->defaultLocale;
432
+    }
433
+
434
+    /**
435
+     * Sets the locale string for this request.
436
+     * 
437
+     * @param  string  $locale
438
+     * 
439
+     * @return \Syscodes\Http\Request
440
+     */
441
+    public function setLocale($locale)
442
+    {
443
+        if ( ! in_array($locale, $this->validLocales)) {
444
+            $locale = $this->defaultLocale;
445
+        }
446 446
 		
447
-		$this->languages = $locale;
448
-
449
-		try {
450
-		    if (class_exists('Locale', false)) {
451
-				Locale::setDefault($locale);
452
-			}
453
-		} catch (Exception $exception) {}
454
-
455
-		return $this;
456
-	}
457
-
458
-	/**
459
-	 * Returns the full request string.
460
-	 *
461
-	 * @return string|null  The Request string
462
-	 */
463
-	public function get() 
464
-	{
465
-		if ($request = static::active()) {
466
-			return $request->uri->get();
467
-		}
468
-
469
-		return null;
470
-	}
471
-
472
-	/**
473
-	 * Get the JSON payload for the request.
474
-	 * 
475
-	 * @param  string|null  $key  
476
-	 * @param  mixed  $default  
477
-	 * 
478
-	 * @return \Syscodes\Http\Contributors\Parameters|mixed
479
-	 */
480
-	public function json($key = null, $default = null)
481
-	{
482
-		if ( ! isset($this->json)) {
483
-			$this->json = new Parameters((array) json_decode($this->getContent(), true));
484
-		}
485
-
486
-		if (is_null($key)) {
487
-			return $this->json;
488
-		}
489
-
490
-		return Arr::get($this->json->all(), $key, $default);
491
-	}
492
-
493
-	/**
494
-	 * Set the JSON payload for the request
495
-	 * 
496
-	 * @param  \Syscodes\Http\Contributors\Parameters  $json
497
-	 * 
498
-	 * @return $this
499
-	 */
500
-	public function setJson($json)
501
-	{
502
-		$this->json = $json;
503
-
504
-		return $this;
505
-	}
506
-
507
-	/**
508
-	 * Returns whether this is an AJAX request or not.
509
-	 *
510
-	 * @return bool
511
-	 */
512
-	public function isXmlHttpRequest()
513
-	{
514
-		return ! empty($this->server->get('HTTP_X_REQUESTED_WITH')) && 
515
-				strtolower($this->server->get('HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest';
516
-	}
517
-
518
-	/**
519
-	 * Returns the input method used (GET, POST, DELETE, etc.).
520
-	 *
521
-	 * @return string
522
-	 * 
523
-	 * @throws \LogicException  
524
-	 */
525
-	public function getmethod()
526
-	{
527
-		if (null !== $this->method) {
528
-			return $this->method;
529
-		}
447
+        $this->languages = $locale;
448
+
449
+        try {
450
+            if (class_exists('Locale', false)) {
451
+                Locale::setDefault($locale);
452
+            }
453
+        } catch (Exception $exception) {}
454
+
455
+        return $this;
456
+    }
457
+
458
+    /**
459
+     * Returns the full request string.
460
+     *
461
+     * @return string|null  The Request string
462
+     */
463
+    public function get() 
464
+    {
465
+        if ($request = static::active()) {
466
+            return $request->uri->get();
467
+        }
468
+
469
+        return null;
470
+    }
471
+
472
+    /**
473
+     * Get the JSON payload for the request.
474
+     * 
475
+     * @param  string|null  $key  
476
+     * @param  mixed  $default  
477
+     * 
478
+     * @return \Syscodes\Http\Contributors\Parameters|mixed
479
+     */
480
+    public function json($key = null, $default = null)
481
+    {
482
+        if ( ! isset($this->json)) {
483
+            $this->json = new Parameters((array) json_decode($this->getContent(), true));
484
+        }
485
+
486
+        if (is_null($key)) {
487
+            return $this->json;
488
+        }
489
+
490
+        return Arr::get($this->json->all(), $key, $default);
491
+    }
492
+
493
+    /**
494
+     * Set the JSON payload for the request
495
+     * 
496
+     * @param  \Syscodes\Http\Contributors\Parameters  $json
497
+     * 
498
+     * @return $this
499
+     */
500
+    public function setJson($json)
501
+    {
502
+        $this->json = $json;
503
+
504
+        return $this;
505
+    }
506
+
507
+    /**
508
+     * Returns whether this is an AJAX request or not.
509
+     *
510
+     * @return bool
511
+     */
512
+    public function isXmlHttpRequest()
513
+    {
514
+        return ! empty($this->server->get('HTTP_X_REQUESTED_WITH')) && 
515
+                strtolower($this->server->get('HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest';
516
+    }
517
+
518
+    /**
519
+     * Returns the input method used (GET, POST, DELETE, etc.).
520
+     *
521
+     * @return string
522
+     * 
523
+     * @throws \LogicException  
524
+     */
525
+    public function getmethod()
526
+    {
527
+        if (null !== $this->method) {
528
+            return $this->method;
529
+        }
530 530
 		
531
-		$method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
531
+        $method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
532 532
 		
533
-		if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
534
-			return $this->method = $method;
535
-		}
533
+        if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
534
+            return $this->method = $method;
535
+        }
536 536
 		
537
-		if ( ! preg_match('~^[A-Z]++$#~D', $method)) {
538
-			throw new logicException(sprintf('Invalid method override "%s"', $method));
539
-		}
540
-
541
-		return $this->method = $method;
542
-	}
543
-
544
-	/**
545
-	 * Sets the request method.
546
-	 *
547
-	 * @param  string  $method  
548
-	 *
549
-	 * @return string
550
-	 */
551
-	public function setMethod(string $method) 
552
-	{
553
-		$this->method = null;
554
-
555
-		$this->server->set('REQUEST_METHOD', $method);
556
-	}
537
+        if ( ! preg_match('~^[A-Z]++$#~D', $method)) {
538
+            throw new logicException(sprintf('Invalid method override "%s"', $method));
539
+        }
540
+
541
+        return $this->method = $method;
542
+    }
543
+
544
+    /**
545
+     * Sets the request method.
546
+     *
547
+     * @param  string  $method  
548
+     *
549
+     * @return string
550
+     */
551
+    public function setMethod(string $method) 
552
+    {
553
+        $this->method = null;
554
+
555
+        $this->server->set('REQUEST_METHOD', $method);
556
+    }
557 557
 	
558
-	/**
559
-	 * Determine if the current request URI matches a pattern.
560
-	 * 
561
-	 * @param  mixed  ...$patterns
562
-	 * 
563
-	 * @return bool
564
-	 */
565
-	public function is(...$patterns)
566
-	{
567
-		$path = $this->decodedPath();
558
+    /**
559
+     * Determine if the current request URI matches a pattern.
560
+     * 
561
+     * @param  mixed  ...$patterns
562
+     * 
563
+     * @return bool
564
+     */
565
+    public function is(...$patterns)
566
+    {
567
+        $path = $this->decodedPath();
568 568
 		
569
-		foreach ($patterns as $pattern) {
570
-			if (Str::is($pattern, $path)) {
571
-				return true;
572
-			}
573
-		}
574
-
575
-		return false;
576
-	}
577
-
578
-	/**
579
-	 * Determine if the route name matches a given pattern.
580
-	 * 
581
-	 * @param  mixed  ...$patterns
582
-	 * 
583
-	 * @return bool
584
-	 */
585
-	public function routeIs(...$patterns)
586
-	{
587
-		return $this->route() && $this->route()->is(...$patterns);
588
-	}
589
-
590
-	/**
591
-	 * Get the route handling the request.
592
-	 * 
593
-	 * @param  string|null  $param  
594
-	 * @param  mixed  $default  
595
-	 * 
596
-	 * @return \Syscodes\Routing\Route|object|string|null
597
-	 */
598
-	public function route($param = null, $default = null)
599
-	{
600
-		$route = $this->getRoute();
601
-
602
-		if (is_null($route) || is_null($param)) {
603
-			return $route;
604
-		}
605
-
606
-		return $route->parameter($param, $default);
607
-	}
608
-
609
-	/**
610
-	 * Get the current decoded path info for the request.
611
-	 * 
612
-	 * @return string
613
-	 */
614
-	public function decodedPath()
615
-	{
616
-		return rawurldecode($this->path());
617
-	}
618
-
619
-	/**
620
-	 * Get the current path info for the request.
621
-	 * 
622
-	 * @return string
623
-	 */
624
-	public function path()
625
-	{
626
-		$path = trim($this->getPathInfo(), '/');
627
-
628
-		return $path == '' ? '/' : $path;
629
-	}
630
-
631
-	/**
632
-	 * Retunrs the request body content.
633
-	 * 
634
-	 * @return string
635
-	 */
636
-	public function getContent()
637
-	{
638
-		if (null === $this->content || false === $this->content)
639
-		{
640
-			$this->content = file_get_contents('php://input');
641
-		}
642
-
643
-		return $this->content;
644
-	}
645
-
646
-	/**
647
-	 * Returns the path being requested relative to the executed script. 
648
-	 * 
649
-	 * @return string
650
-	 */
651
-	public function getPathInfo()
652
-	{
653
-		if (null === $this->pathInfo)
654
-		{
655
-			$this->pathInfo = $this->http->parsePathInfo();
656
-		}
657
-
658
-		return $this->pathInfo;
659
-	}
660
-
661
-	/**
662
-	 * Returns the root URL from which this request is executed.
663
-	 * 
664
-	 * @return string
665
-	 */
666
-	public function getBaseUrl()
667
-	{
668
-		if (null === $this->baseUrl)
669
-		{
670
-			$this->baseUrl = $this->http->parseBaseUrl();
671
-		}
672
-
673
-		return $this->baseUrl;
674
-	}
675
-
676
-	/**
677
-	 * Returns the requested URI.
678
-	 * 
679
-	 * @return string
680
-	 */
681
-	public function getRequestUri()
682
-	{
683
-		if (null === $this->requestToUri) {
684
-			$this->requestToUri = $this->http->parseRequestUri();
685
-		}
686
-
687
-		return $this->requestToUri;
688
-	}
569
+        foreach ($patterns as $pattern) {
570
+            if (Str::is($pattern, $path)) {
571
+                return true;
572
+            }
573
+        }
574
+
575
+        return false;
576
+    }
577
+
578
+    /**
579
+     * Determine if the route name matches a given pattern.
580
+     * 
581
+     * @param  mixed  ...$patterns
582
+     * 
583
+     * @return bool
584
+     */
585
+    public function routeIs(...$patterns)
586
+    {
587
+        return $this->route() && $this->route()->is(...$patterns);
588
+    }
589
+
590
+    /**
591
+     * Get the route handling the request.
592
+     * 
593
+     * @param  string|null  $param  
594
+     * @param  mixed  $default  
595
+     * 
596
+     * @return \Syscodes\Routing\Route|object|string|null
597
+     */
598
+    public function route($param = null, $default = null)
599
+    {
600
+        $route = $this->getRoute();
601
+
602
+        if (is_null($route) || is_null($param)) {
603
+            return $route;
604
+        }
605
+
606
+        return $route->parameter($param, $default);
607
+    }
608
+
609
+    /**
610
+     * Get the current decoded path info for the request.
611
+     * 
612
+     * @return string
613
+     */
614
+    public function decodedPath()
615
+    {
616
+        return rawurldecode($this->path());
617
+    }
618
+
619
+    /**
620
+     * Get the current path info for the request.
621
+     * 
622
+     * @return string
623
+     */
624
+    public function path()
625
+    {
626
+        $path = trim($this->getPathInfo(), '/');
627
+
628
+        return $path == '' ? '/' : $path;
629
+    }
630
+
631
+    /**
632
+     * Retunrs the request body content.
633
+     * 
634
+     * @return string
635
+     */
636
+    public function getContent()
637
+    {
638
+        if (null === $this->content || false === $this->content)
639
+        {
640
+            $this->content = file_get_contents('php://input');
641
+        }
642
+
643
+        return $this->content;
644
+    }
645
+
646
+    /**
647
+     * Returns the path being requested relative to the executed script. 
648
+     * 
649
+     * @return string
650
+     */
651
+    public function getPathInfo()
652
+    {
653
+        if (null === $this->pathInfo)
654
+        {
655
+            $this->pathInfo = $this->http->parsePathInfo();
656
+        }
657
+
658
+        return $this->pathInfo;
659
+    }
660
+
661
+    /**
662
+     * Returns the root URL from which this request is executed.
663
+     * 
664
+     * @return string
665
+     */
666
+    public function getBaseUrl()
667
+    {
668
+        if (null === $this->baseUrl)
669
+        {
670
+            $this->baseUrl = $this->http->parseBaseUrl();
671
+        }
672
+
673
+        return $this->baseUrl;
674
+    }
675
+
676
+    /**
677
+     * Returns the requested URI.
678
+     * 
679
+     * @return string
680
+     */
681
+    public function getRequestUri()
682
+    {
683
+        if (null === $this->requestToUri) {
684
+            $this->requestToUri = $this->http->parseRequestUri();
685
+        }
686
+
687
+        return $this->requestToUri;
688
+    }
689 689
 	
690
-	/**
691
-	 * Gets the request's scheme.
692
-	 * 
693
-	 * @return string
694
-	 */
695
-	public function getScheme()
696
-	{
697
-		return $this->secure() ? $this->uri->setScheme('https') : $this->uri->setScheme('http');
698
-	}
699
-
700
-	/**
701
-	 * Returns the host name.
702
-	 * 
703
-	 * @return void
704
-	 */
705
-	public function getHost()
706
-	{
707
-		if ($forwardedHost = $this->server->get('HTTP_X_FORWARDED_HOST')) {
708
-			$host = $forawardedHost[0];
709
-		} elseif ( ! $host = $this->headers->get('HOST')) {
710
-			if ( ! $host = $this->server->get('SERVER_NAME')) {
711
-				$host = $this->server->get('REMOTE_ADDR', '');
712
-			}
713
-		}
714
-
715
-		$host = $_SERVER['SERVER_NAME'];
716
-
717
-		$host = strtolower(preg_replace('/:\d+$/', '', trim(($host))));
690
+    /**
691
+     * Gets the request's scheme.
692
+     * 
693
+     * @return string
694
+     */
695
+    public function getScheme()
696
+    {
697
+        return $this->secure() ? $this->uri->setScheme('https') : $this->uri->setScheme('http');
698
+    }
699
+
700
+    /**
701
+     * Returns the host name.
702
+     * 
703
+     * @return void
704
+     */
705
+    public function getHost()
706
+    {
707
+        if ($forwardedHost = $this->server->get('HTTP_X_FORWARDED_HOST')) {
708
+            $host = $forawardedHost[0];
709
+        } elseif ( ! $host = $this->headers->get('HOST')) {
710
+            if ( ! $host = $this->server->get('SERVER_NAME')) {
711
+                $host = $this->server->get('REMOTE_ADDR', '');
712
+            }
713
+        }
714
+
715
+        $host = $_SERVER['SERVER_NAME'];
716
+
717
+        $host = strtolower(preg_replace('/:\d+$/', '', trim(($host))));
718 718
 		
719
-		return $host;
720
-	}
721
-
722
-	/**
723
-	 * Returns the port on which the request is made.
724
-	 * 
725
-	 * @return int
726
-	 */
727
-	public function getPort()
728
-	{
729
-		if ( ! $this->server->get('HTTP_HOST')) 
730
-		{
731
-			return $this->server->get('SERVER_PORT');
732
-		}
719
+        return $host;
720
+    }
721
+
722
+    /**
723
+     * Returns the port on which the request is made.
724
+     * 
725
+     * @return int
726
+     */
727
+    public function getPort()
728
+    {
729
+        if ( ! $this->server->get('HTTP_HOST')) 
730
+        {
731
+            return $this->server->get('SERVER_PORT');
732
+        }
733 733
 		
734
-		return 'https' === $this->getScheme() ? $this->uri->setPort(443) : $this->uri->setPort(80);
735
-	}
736
-
737
-	/**
738
-	 * Returns the HTTP host being requested.
739
-	 * 
740
-	 * @return string
741
-	 */
742
-	public function getHttpHost()
743
-	{
744
-		$scheme = $this->getScheme();
745
-		$port   = $this->getPort();
746
-
747
-		if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port))		
748
-		{
749
-			return $this->getHost();
750
-		}
751
-
752
-		return $this->getHost().':'.$port;
753
-	}
754
-
755
-	/**
756
-	 * Gets the scheme and HTTP host.
757
-	 * 
758
-	 * @return string
759
-	 */
760
-	public function getSchemeWithHttpHost()
761
-	{
762
-		return $this->getScheme().'://'.$this->getHttpHost();
763
-	}
764
-
765
-	/**
766
-	 * Get the root URL for the application.
767
-	 * 
768
-	 * @return string
769
-	 */
770
-	public function root()
771
-	{
772
-		return rtrim($this->getSchemeWithHttpHost().$this->getBaseUrl(), '/');
773
-	}
774
-
775
-	/**
776
-	 * Get the URL for the request.
777
-	 * 
778
-	 * @return string
779
-	 */
780
-	public function url()
781
-	{
782
-		return trim(preg_replace('/\?.*/', '', $this->get()), '/');
783
-	}
784
-
785
-	/**
786
-	 * Returns the referer.
787
-	 * 
788
-	 * @param  string  $default
789
-	 * 
790
-	 * @return string
791
-	 */
792
-	public function referer(string $default = '')
793
-	{
794
-		return $this->server->get('HTTP_REFERER', $default);
795
-	}
734
+        return 'https' === $this->getScheme() ? $this->uri->setPort(443) : $this->uri->setPort(80);
735
+    }
736
+
737
+    /**
738
+     * Returns the HTTP host being requested.
739
+     * 
740
+     * @return string
741
+     */
742
+    public function getHttpHost()
743
+    {
744
+        $scheme = $this->getScheme();
745
+        $port   = $this->getPort();
746
+
747
+        if (('http' === $scheme && 80 === $port) || ('https' === $scheme && 443 === $port))		
748
+        {
749
+            return $this->getHost();
750
+        }
751
+
752
+        return $this->getHost().':'.$port;
753
+    }
754
+
755
+    /**
756
+     * Gets the scheme and HTTP host.
757
+     * 
758
+     * @return string
759
+     */
760
+    public function getSchemeWithHttpHost()
761
+    {
762
+        return $this->getScheme().'://'.$this->getHttpHost();
763
+    }
764
+
765
+    /**
766
+     * Get the root URL for the application.
767
+     * 
768
+     * @return string
769
+     */
770
+    public function root()
771
+    {
772
+        return rtrim($this->getSchemeWithHttpHost().$this->getBaseUrl(), '/');
773
+    }
774
+
775
+    /**
776
+     * Get the URL for the request.
777
+     * 
778
+     * @return string
779
+     */
780
+    public function url()
781
+    {
782
+        return trim(preg_replace('/\?.*/', '', $this->get()), '/');
783
+    }
784
+
785
+    /**
786
+     * Returns the referer.
787
+     * 
788
+     * @param  string  $default
789
+     * 
790
+     * @return string
791
+     */
792
+    public function referer(string $default = '')
793
+    {
794
+        return $this->server->get('HTTP_REFERER', $default);
795
+    }
796 796
 	
797
-	/**
798
-	 * Attempts to detect if the current connection is secure through 
799
-	 * over HTTPS protocol.
800
-	 * 
801
-	 * @return bool
802
-	 */
803
-	public function secure()
804
-	{
805
-		if ( ! empty($this->server->get('HTTPS')) && strtolower($this->server->get('HTTPS')) !== 'off') {
806
-			return true;
807
-		} elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $this->server->get('HTTP_X_FORWARDED_PROTO') === 'https') {
808
-			return true;
809
-		} elseif ( ! empty($this->server->get('HTTP_FRONT_END_HTTPS')) && strtolower($this->server->get('HTTP_FRONT_END_HTTPS')) !== 'off') {
810
-			return true;
811
-		}
812
-
813
-		return false;
814
-	}
815
-
816
-	/**
817
-	 * Returns the user agent.
818
-	 *
819
-	 * @param  string|null  $default
820
-	 *
821
-	 * @return string
822
-	 */
823
-	public function userAgent(string $default = null)
824
-	{
825
-		return $this->server->get('HTTP_USER_AGENT', $default);
826
-	}
827
-
828
-	/**
829
-	 * Get the route resolver.
830
-	 * 
831
-	 * @return \Syscodes\Routing\Router
832
-	 */
833
-	public function getRoute()
834
-	{
835
-		return app('router');
836
-	}
837
-
838
-	/**
839
-	 * Get an element from the request.
840
-	 * 
841
-	 * @return string[]
842
-	 */
843
-	public function __get($key)
844
-	{
845
-		$all = $this->server->all();
846
-
847
-		if (array_key_exists($key, $all)) {
848
-			return $all[$key];
849
-		} else {
850
-			return $key;
851
-		}
852
-	}
853
-
854
-	/**
855
-	 * Returns the Request as an HTTP string.
856
-	 * 
857
-	 * @return string
858
-	 */
859
-	public function __toString()
860
-	{
861
-		try
862
-		{
863
-			$content = $this->getContent();
864
-		}
865
-		catch (LogicException $e)
866
-		{
867
-			if (PHP_VERSION_ID > 70400)
868
-			{
869
-				throw $e;
870
-			}
871
-
872
-			return trigger_error($e, E_USER_ERROR);
873
-		}
874
-
875
-		$cookieHeader = '';
876
-		$cookies      = [];
877
-
878
-		foreach ($this->cookies as $key => $value)
879
-		{
880
-			$cookies[]= "{$key} = {$value}";
881
-		}
882
-
883
-		if ( ! empty($cookies))
884
-		{
885
-			$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
886
-		}
797
+    /**
798
+     * Attempts to detect if the current connection is secure through 
799
+     * over HTTPS protocol.
800
+     * 
801
+     * @return bool
802
+     */
803
+    public function secure()
804
+    {
805
+        if ( ! empty($this->server->get('HTTPS')) && strtolower($this->server->get('HTTPS')) !== 'off') {
806
+            return true;
807
+        } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $this->server->get('HTTP_X_FORWARDED_PROTO') === 'https') {
808
+            return true;
809
+        } elseif ( ! empty($this->server->get('HTTP_FRONT_END_HTTPS')) && strtolower($this->server->get('HTTP_FRONT_END_HTTPS')) !== 'off') {
810
+            return true;
811
+        }
812
+
813
+        return false;
814
+    }
815
+
816
+    /**
817
+     * Returns the user agent.
818
+     *
819
+     * @param  string|null  $default
820
+     *
821
+     * @return string
822
+     */
823
+    public function userAgent(string $default = null)
824
+    {
825
+        return $this->server->get('HTTP_USER_AGENT', $default);
826
+    }
827
+
828
+    /**
829
+     * Get the route resolver.
830
+     * 
831
+     * @return \Syscodes\Routing\Router
832
+     */
833
+    public function getRoute()
834
+    {
835
+        return app('router');
836
+    }
837
+
838
+    /**
839
+     * Get an element from the request.
840
+     * 
841
+     * @return string[]
842
+     */
843
+    public function __get($key)
844
+    {
845
+        $all = $this->server->all();
846
+
847
+        if (array_key_exists($key, $all)) {
848
+            return $all[$key];
849
+        } else {
850
+            return $key;
851
+        }
852
+    }
853
+
854
+    /**
855
+     * Returns the Request as an HTTP string.
856
+     * 
857
+     * @return string
858
+     */
859
+    public function __toString()
860
+    {
861
+        try
862
+        {
863
+            $content = $this->getContent();
864
+        }
865
+        catch (LogicException $e)
866
+        {
867
+            if (PHP_VERSION_ID > 70400)
868
+            {
869
+                throw $e;
870
+            }
871
+
872
+            return trigger_error($e, E_USER_ERROR);
873
+        }
874
+
875
+        $cookieHeader = '';
876
+        $cookies      = [];
877
+
878
+        foreach ($this->cookies as $key => $value)
879
+        {
880
+            $cookies[]= "{$key} = {$value}";
881
+        }
882
+
883
+        if ( ! empty($cookies))
884
+        {
885
+            $cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
886
+        }
887 887
 		
888
-		return sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
889
-			$this->headers.
890
-			$cookieHeader."\r\n".
891
-			$content;
892
-	}
893
-
894
-	/**
895
-	 * Clones the current request.
896
-	 * 
897
-	 * @return void
898
-	 */
899
-	public function __clone()
900
-	{
901
-		$this->request = clone $this->request;
902
-		$this->cookies = clone $this->cookies;
903
-		$this->files   = clone $this->files;
904
-		$this->server  = clone $this->server;
905
-		$this->headers = clone $this->headers;
906
-	}
888
+        return sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
889
+            $this->headers.
890
+            $cookieHeader."\r\n".
891
+            $content;
892
+    }
893
+
894
+    /**
895
+     * Clones the current request.
896
+     * 
897
+     * @return void
898
+     */
899
+    public function __clone()
900
+    {
901
+        $this->request = clone $this->request;
902
+        $this->cookies = clone $this->cookies;
903
+        $this->files   = clone $this->files;
904
+        $this->server  = clone $this->server;
905
+        $this->headers = clone $this->headers;
906
+    }
907 907
 }
908 908
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Http/URI.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@
 block discarded – undo
258 258
 	 */
259 259
 	public function getSegments()
260 260
 	{
261
-		return array_values(array_filter($this->segments, function ($value) {
261
+		return array_values(array_filter($this->segments, function($value) {
262 262
 			return $value != '';
263 263
 		}));
264 264
 	}
Please login to merge, or discard this patch.
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -34,497 +34,497 @@
 block discarded – undo
34 34
  */
35 35
 class URI
36 36
 {
37
-	/**
38
-	 * Returns default schemes/ports.
39
-	 * 
40
-	 * @var array $defaultPorts
41
-	 */
42
-	protected $defaultPorts = [
43
-		'http'  => 80,
44
-		'https' => 443,
45
-		'ftp'   => 21,
46
-		'sftp'  => 22
47
-	];
48
-
49
-	/**
50
-	 * The name of any fragment.
51
-	 * 
52
-	 * @var string $fragment
53
-	 */
54
-	protected $fragment = '';
55
-
56
-	/**
57
-	 * The URI Host.
58
-	 * 
59
-	 * @var string $host
60
-	 */
61
-	protected $host;
37
+    /**
38
+     * Returns default schemes/ports.
39
+     * 
40
+     * @var array $defaultPorts
41
+     */
42
+    protected $defaultPorts = [
43
+        'http'  => 80,
44
+        'https' => 443,
45
+        'ftp'   => 21,
46
+        'sftp'  => 22
47
+    ];
48
+
49
+    /**
50
+     * The name of any fragment.
51
+     * 
52
+     * @var string $fragment
53
+     */
54
+    protected $fragment = '';
55
+
56
+    /**
57
+     * The URI Host.
58
+     * 
59
+     * @var string $host
60
+     */
61
+    protected $host;
62 62
 	
63
-	/**
64
-	 * The URI User Password.
65
-	 * 
66
-	 * @var string $password
67
-	 */
68
-	protected $password;
69
-
70
-	/**
71
-	 * The URI path.
72
-	 * 
73
-	 * @var string $path
74
-	 */
75
-	protected $path;
76
-
77
-	/**
78
-	 * The URI Port.
79
-	 * 
80
-	 * @var int $port
81
-	 */
82
-	protected $port;
83
-
84
-	/**
85
-	 * The query string.
86
-	 * 
87
-	 * @var string $query
88
-	 */
89
-	protected $query;
90
-
91
-	/**
92
-	 * The URI Scheme.
93
-	 * 
94
-	 * @var string $scheme
95
-	 */
96
-	protected $scheme = 'http';
97
-
98
-	/**
99
-	 * The URI segments.
100
-	 *
101
-	 * @var array $segments
102
-	 */
103
-	protected $segments = [];
104
-
105
-	/**
106
-	 * Whether passwords should be shown in userInfo/authority calls.
107
-	 * 
108
-	 * @var boolean $showPassword
109
-	 */
110
-	protected $showPassword = false;
63
+    /**
64
+     * The URI User Password.
65
+     * 
66
+     * @var string $password
67
+     */
68
+    protected $password;
69
+
70
+    /**
71
+     * The URI path.
72
+     * 
73
+     * @var string $path
74
+     */
75
+    protected $path;
76
+
77
+    /**
78
+     * The URI Port.
79
+     * 
80
+     * @var int $port
81
+     */
82
+    protected $port;
83
+
84
+    /**
85
+     * The query string.
86
+     * 
87
+     * @var string $query
88
+     */
89
+    protected $query;
90
+
91
+    /**
92
+     * The URI Scheme.
93
+     * 
94
+     * @var string $scheme
95
+     */
96
+    protected $scheme = 'http';
97
+
98
+    /**
99
+     * The URI segments.
100
+     *
101
+     * @var array $segments
102
+     */
103
+    protected $segments = [];
104
+
105
+    /**
106
+     * Whether passwords should be shown in userInfo/authority calls.
107
+     * 
108
+     * @var boolean $showPassword
109
+     */
110
+    protected $showPassword = false;
111 111
 	
112
-	/**
113
-	 * The URI User Info.
114
-	 * 
115
-	 * @var string $user
116
-	 */
117
-	protected $user;
118
-
119
-	/**
120
-	 * Constructor. The URI class instance.
121
-	 * 
122
-	 * @param  string|null  $uri  
123
-	 * 
124
-	 * @return void
125
-	 * 
126
-	 * @throws \Syscodes\Http\Exceptions\HttpURIException
127
-	 */
128
-	public function __construct(string $uri = null)
129
-	{
130
-		if ( ! is_null($uri)) {
131
-			$this->setUri($uri);
132
-		}
133
-	}
134
-
135
-	/**
136
-	 * Sets and overwrites any current URI information.
137
-	 * 
138
-	 * @param  string|null  $uri  
139
-	 * 
140
-	 * @return mixed
141
-	 * 
142
-	 * @throws \Syscodes\Http\Exceptions\HttpURIException
143
-	 */
144
-	public function setUri(string $uri = null)
145
-	{
146
-		if ( ! is_null($uri)) {
147
-			$parts = parse_url($uri);
148
-
149
-			if ($parts === false) {
150
-				throw HttpURIException::UnableToParseURI($uri);
151
-			}
152
-
153
-			$this->applyParts($parts);
154
-		}
155
-
156
-		return $this;
157
-	}
158
-
159
-	/**
160
-	 * Returns the full URI string.
161
-	 *
162
-	 * @return string  The URI string
163
-	 */
164
-	public function get()
165
-	{
166
-		return '/'.ltrim($this->path, '/');
167
-	}
168
-
169
-	/**
170
-	 * Sets of URI string.
171
-	 * 
172
-	 * @param  string  $uri
173
-	 * 
174
-	 * @return $this
175
-	 */
176
-	public function set($uri)
177
-	{
178
-		$this->path = $uri;
179
-
180
-		return $this;
181
-	}
182
-
183
-	/**
184
-	 * Retrieve the path component of the URI. The path can either be empty or absolute 
185
-	 * (starting with a slash) or rootless (not starting with a slash).
186
-	 * 
187
-	 * @return string
188
-	 */
189
-	public function getPath()
190
-	{
191
-		return (is_null($this->path) ? '' : $this->path);
192
-	}
193
-
194
-	/**
195
-	 * Sets the path portion of the URI.
196
-	 * 
197
-	 * @param  string  $path
198
-	 *
199
-	 * @return void
200
-	 */
201
-	public function setPath(string $path) 
202
-	{
203
-		$this->path = $this->filterPath($path);
204
-
205
-		$this->filterSegments($this->path);
206
-
207
-		return $this;
208
-	} 
209
-
210
-	/**
211
-	 * Encodes any dangerous characters.
212
-	 * 
213
-	 * @param  string|null  $path
214
-	 * 
215
-	 * @return string
216
-	 */
217
-	protected function filterPath(string $path = null)
218
-	{
219
-		$path = urldecode($path);
220
-
221
-		return $path;
222
-	}
223
-
224
-	/**
225
-	 * Filter the segments of path.
226
-	 * 
227
-	 * @param  string  $uri
228
-	 * 
229
-	 * @return string[]
230
-	 */
231
-	protected function filterSegments($uri)
232
-	{
233
-		$this->segments = (empty($uri) ? [] : explode('/', $uri));
234
-	}
235
-
236
-	/**
237
-	 * Get the specified URI segment, return default if it doesn't exist.
238
-	 * Segment index is 1 based, not 0 based.
239
-	 *
240
-	 * @param  int  $index  The 1-based segment index
241
-	 * @param  mixed  $default  The default value
242
-	 *
243
-	 * @return mixed
244
-	 */
245
-	public function getSegment(int $index, $default = null)
246
-	{
247
-		return Arr::get($this->getSegments(), $index - 1, $default);
248
-	}
249
-
250
-	/**
251
-	 * Returns the segments of the path as an array.
252
-	 *
253
-	 * @return array  The URI segments
254
-	 */
255
-	public function getSegments()
256
-	{
257
-		return array_values(array_filter($this->segments, function ($value) {
258
-			return $value != '';
259
-		}));
260
-	}
261
-
262
-	/**
263
-	 * Returns the total number of segment.
264
-	 *
265
-	 * @return int  
266
-	 */
267
-	public function getTotalSegments()
268
-	{
269
-		return count($this->getSegments());
270
-	}
271
-
272
-	/**
273
-	 * Retrieve the scheme component of the URI.
274
-	 * 
275
-	 * @return string
276
-	 */
277
-	public function getScheme()
278
-	{
279
-		return $this->scheme;
280
-	}
281
-
282
-	/**
283
-	 * Sets the scheme for this URI.
284
-	 * 
285
-	 * @param  string  $str
286
-	 * 
287
-	 * @return $this
288
-	 */
289
-	public function setScheme(string $str)
290
-	{
291
-		$str = preg_replace('~:(//)?$~', '', strtolower($str));
292
-
293
-		$this->scheme = $str;
294
-
295
-		return $this->scheme;
296
-	}
297
-
298
-	/**
299
-	 * Retrieve the user component of the URI.
300
-	 * 
301
-	 * @return string|null
302
-	 */
303
-	public function getUserInfo()
304
-	{
305
-		$user = $this->user;
306
-
307
-		if ($this->showPassword === true && ! empty($this->password)) {
308
-			$user .= ":$this->password";
309
-		}
310
-
311
-		return $user;
312
-	}
313
-
314
-	/**
315
-	 * Sets the userInfo/Authority portion of the URI.
316
-	 * 
317
-	 * @param  string  $user
318
-	 * @param  string  $pass
319
-	 * 
320
-	 * @return $this
321
-	 */
322
-	public function setUserInfo(string $user, string $pass)
323
-	{
324
-		$this->user     = trim($user);
325
-		$this->password = trim($pass);
326
-
327
-		return $this;
328
-	}
329
-
330
-	/**
331
-	 * Temporarily sets the URI to show a password in userInfo.
332
-	 * 
333
-	 * @param  boolean  $option  
334
-	 * 
335
-	 * @return $this
336
-	 */
337
-	public function showPassword(bool $option = true)
338
-	{
339
-		$this->password = $option;
340
-
341
-		return $this->password;
342
-	}
343
-
344
-	/**
345
-	 * Retrieve the authority component of the URI.
346
-	 * 
347
-	 * @param  boolean  $ignore  
348
-	 * 
349
-	 * @return string
350
-	 */
351
-	public function getAuthority(bool $ignore = false)
352
-	{
353
-		if (empty($this->host)) {
354
-			return '';
355
-		}
356
-
357
-		$authority = $this->host;
358
-
359
-		if ( ! empty($this->getUserInfo())) {
360
-			$authority = $this->getUserInfo().'@'.$authority;
361
-		}
362
-
363
-		if ( ! empty($this->port) && ! $ignore) {
364
-			if ($this->port !== $this->defaultPorts[$this->scheme]) {
365
-				$authority .= ":$this->port";
366
-			}
367
-		}
368
-
369
-		$this->showPassword = false;
370
-
371
-		return $authority;
372
-	}
373
-
374
-	/**
375
-	 * Parses the given string an saves the appropriate authority pieces.
376
-	 * 
377
-	 * @param  string  $str
378
-	 * 
379
-	 * @return $this
380
-	 */
381
-	public function setAuthority(string $str)
382
-	{
383
-		$parts = parse_url($str);
384
-
385
-		if (empty($parts['host']) && ! empty($parts['path'])) {
386
-			$parts['host'] = $parts['path'];
387
-			unset($parts['path']);
388
-		}
389
-
390
-		$this->applyParts($parts);
391
-
392
-		return $this;
393
-	}
394
-
395
-	/**
396
-	 * Retrieve the host component of the URI.
397
-	 * 
398
-	 * @return string
399
-	 */
400
-	public function getHost()
401
-	{
402
-		return $this->host;
403
-	}
404
-
405
-	/**
406
-	 * Sets the host name to use.
407
-	 * 
408
-	 * @param  string  $str
409
-	 * 
410
-	 * @return $this
411
-	 */
412
-	public function setHost(string $str)
413
-	{
414
-		$this->host = trim($str);
415
-
416
-		return $this->host;
417
-	}
418
-
419
-	/**
420
-	 * Retrieve the port component of the URI.
421
-	 * 
422
-	 * @return int|null
423
-	 */
424
-	public function getPort()
425
-	{
426
-		return $this->port;
427
-	}
428
-
429
-	/**
430
-	 * Sets the port portion of the URI.
431
-	 * 
432
-	 * @param  int|null  $port  
433
-	 * 
434
-	 * @return string
435
-	 */
436
-	public function setPort(int $port = null)
437
-	{
438
-		if (is_null($port)) {
439
-			return $this;
440
-		}
441
-
442
-		if ($port <= 0 || $port > 65355) {
443
-			throw HttpURIException::invalidPort($port);
444
-		}
445
-
446
-		$this->port = $port;
447
-
448
-		return $this->port;
449
-	}
450
-
451
-	/**
452
-	 * Retrieve a URI fragment.
453
-	 * 
454
-	 * @return string
455
-	 */
456
-	public function getFragment()
457
-	{
458
-		return is_null($this->fragment) ? '' : $this->fragment;
459
-	}
460
-
461
-	/**
462
-	 * Sets the fragment portion of the URI.
463
-	 * 
464
-	 * @param  string  $str
465
-	 * 
466
-	 * @return $this
467
-	 */
468
-	public function setFragment(string $str)
469
-	{
470
-		$this->fragment = trim($str, '# ');
471
-
472
-		return $this->fragment;
473
-	}
474
-
475
-	/**
476
-	 * Saves our parts from a parse_url call.
477
-	 * 
478
-	 * @param  array  $parts
479
-	 * 
480
-	 * @return mixed
481
-	 */
482
-	public function applyParts(array $paths)
483
-	{
484
-		if (isset($parts['scheme'])) {
485
-			$this->SetScheme(rtrim($parts['scheme'], ':/'));
486
-		} else {
487
-			$this->setScheme('http');
488
-		}
489
-
490
-		if ( ! empty($parts['host'])) {
491
-			$this->host = $parts['host'];
492
-		}
493
-
494
-		if (isset($parts['port'])) {
495
-			if ( ! is_null($parts['port'])) {
496
-				$this->port = $parts['port'];
497
-			}
498
-		}
499
-
500
-		if ( ! empty($parts['user'])) {
501
-			$this->user = $parts['user'];
502
-		}
503
-
504
-		if ( ! empty($parts['pass'])) {
505
-			$this->password = $parts['pass'];
506
-		}
507
-
508
-		if ( ! empty($parts['path'])) {
509
-			$this->path = $this->filterPath($parts['path']);
510
-		}
511
-
512
-		if ( ! empty($parts['fragment'])) {
513
-			$this->fragment = $parts['fragment'];
514
-		}
515
-
516
-		if ( ! empty($parts['path'])) {
517
-			$this->segments = explode('/', $parts['path'], '/');
518
-		}
519
-	}
520
-
521
-	/**
522
-	 * Returns the URI string.
523
-	 *
524
-	 * @return string
525
-	 */
526
-	public function __toString()
527
-	{
528
-		return (string) $this->getPath();
529
-	}
112
+    /**
113
+     * The URI User Info.
114
+     * 
115
+     * @var string $user
116
+     */
117
+    protected $user;
118
+
119
+    /**
120
+     * Constructor. The URI class instance.
121
+     * 
122
+     * @param  string|null  $uri  
123
+     * 
124
+     * @return void
125
+     * 
126
+     * @throws \Syscodes\Http\Exceptions\HttpURIException
127
+     */
128
+    public function __construct(string $uri = null)
129
+    {
130
+        if ( ! is_null($uri)) {
131
+            $this->setUri($uri);
132
+        }
133
+    }
134
+
135
+    /**
136
+     * Sets and overwrites any current URI information.
137
+     * 
138
+     * @param  string|null  $uri  
139
+     * 
140
+     * @return mixed
141
+     * 
142
+     * @throws \Syscodes\Http\Exceptions\HttpURIException
143
+     */
144
+    public function setUri(string $uri = null)
145
+    {
146
+        if ( ! is_null($uri)) {
147
+            $parts = parse_url($uri);
148
+
149
+            if ($parts === false) {
150
+                throw HttpURIException::UnableToParseURI($uri);
151
+            }
152
+
153
+            $this->applyParts($parts);
154
+        }
155
+
156
+        return $this;
157
+    }
158
+
159
+    /**
160
+     * Returns the full URI string.
161
+     *
162
+     * @return string  The URI string
163
+     */
164
+    public function get()
165
+    {
166
+        return '/'.ltrim($this->path, '/');
167
+    }
168
+
169
+    /**
170
+     * Sets of URI string.
171
+     * 
172
+     * @param  string  $uri
173
+     * 
174
+     * @return $this
175
+     */
176
+    public function set($uri)
177
+    {
178
+        $this->path = $uri;
179
+
180
+        return $this;
181
+    }
182
+
183
+    /**
184
+     * Retrieve the path component of the URI. The path can either be empty or absolute 
185
+     * (starting with a slash) or rootless (not starting with a slash).
186
+     * 
187
+     * @return string
188
+     */
189
+    public function getPath()
190
+    {
191
+        return (is_null($this->path) ? '' : $this->path);
192
+    }
193
+
194
+    /**
195
+     * Sets the path portion of the URI.
196
+     * 
197
+     * @param  string  $path
198
+     *
199
+     * @return void
200
+     */
201
+    public function setPath(string $path) 
202
+    {
203
+        $this->path = $this->filterPath($path);
204
+
205
+        $this->filterSegments($this->path);
206
+
207
+        return $this;
208
+    } 
209
+
210
+    /**
211
+     * Encodes any dangerous characters.
212
+     * 
213
+     * @param  string|null  $path
214
+     * 
215
+     * @return string
216
+     */
217
+    protected function filterPath(string $path = null)
218
+    {
219
+        $path = urldecode($path);
220
+
221
+        return $path;
222
+    }
223
+
224
+    /**
225
+     * Filter the segments of path.
226
+     * 
227
+     * @param  string  $uri
228
+     * 
229
+     * @return string[]
230
+     */
231
+    protected function filterSegments($uri)
232
+    {
233
+        $this->segments = (empty($uri) ? [] : explode('/', $uri));
234
+    }
235
+
236
+    /**
237
+     * Get the specified URI segment, return default if it doesn't exist.
238
+     * Segment index is 1 based, not 0 based.
239
+     *
240
+     * @param  int  $index  The 1-based segment index
241
+     * @param  mixed  $default  The default value
242
+     *
243
+     * @return mixed
244
+     */
245
+    public function getSegment(int $index, $default = null)
246
+    {
247
+        return Arr::get($this->getSegments(), $index - 1, $default);
248
+    }
249
+
250
+    /**
251
+     * Returns the segments of the path as an array.
252
+     *
253
+     * @return array  The URI segments
254
+     */
255
+    public function getSegments()
256
+    {
257
+        return array_values(array_filter($this->segments, function ($value) {
258
+            return $value != '';
259
+        }));
260
+    }
261
+
262
+    /**
263
+     * Returns the total number of segment.
264
+     *
265
+     * @return int  
266
+     */
267
+    public function getTotalSegments()
268
+    {
269
+        return count($this->getSegments());
270
+    }
271
+
272
+    /**
273
+     * Retrieve the scheme component of the URI.
274
+     * 
275
+     * @return string
276
+     */
277
+    public function getScheme()
278
+    {
279
+        return $this->scheme;
280
+    }
281
+
282
+    /**
283
+     * Sets the scheme for this URI.
284
+     * 
285
+     * @param  string  $str
286
+     * 
287
+     * @return $this
288
+     */
289
+    public function setScheme(string $str)
290
+    {
291
+        $str = preg_replace('~:(//)?$~', '', strtolower($str));
292
+
293
+        $this->scheme = $str;
294
+
295
+        return $this->scheme;
296
+    }
297
+
298
+    /**
299
+     * Retrieve the user component of the URI.
300
+     * 
301
+     * @return string|null
302
+     */
303
+    public function getUserInfo()
304
+    {
305
+        $user = $this->user;
306
+
307
+        if ($this->showPassword === true && ! empty($this->password)) {
308
+            $user .= ":$this->password";
309
+        }
310
+
311
+        return $user;
312
+    }
313
+
314
+    /**
315
+     * Sets the userInfo/Authority portion of the URI.
316
+     * 
317
+     * @param  string  $user
318
+     * @param  string  $pass
319
+     * 
320
+     * @return $this
321
+     */
322
+    public function setUserInfo(string $user, string $pass)
323
+    {
324
+        $this->user     = trim($user);
325
+        $this->password = trim($pass);
326
+
327
+        return $this;
328
+    }
329
+
330
+    /**
331
+     * Temporarily sets the URI to show a password in userInfo.
332
+     * 
333
+     * @param  boolean  $option  
334
+     * 
335
+     * @return $this
336
+     */
337
+    public function showPassword(bool $option = true)
338
+    {
339
+        $this->password = $option;
340
+
341
+        return $this->password;
342
+    }
343
+
344
+    /**
345
+     * Retrieve the authority component of the URI.
346
+     * 
347
+     * @param  boolean  $ignore  
348
+     * 
349
+     * @return string
350
+     */
351
+    public function getAuthority(bool $ignore = false)
352
+    {
353
+        if (empty($this->host)) {
354
+            return '';
355
+        }
356
+
357
+        $authority = $this->host;
358
+
359
+        if ( ! empty($this->getUserInfo())) {
360
+            $authority = $this->getUserInfo().'@'.$authority;
361
+        }
362
+
363
+        if ( ! empty($this->port) && ! $ignore) {
364
+            if ($this->port !== $this->defaultPorts[$this->scheme]) {
365
+                $authority .= ":$this->port";
366
+            }
367
+        }
368
+
369
+        $this->showPassword = false;
370
+
371
+        return $authority;
372
+    }
373
+
374
+    /**
375
+     * Parses the given string an saves the appropriate authority pieces.
376
+     * 
377
+     * @param  string  $str
378
+     * 
379
+     * @return $this
380
+     */
381
+    public function setAuthority(string $str)
382
+    {
383
+        $parts = parse_url($str);
384
+
385
+        if (empty($parts['host']) && ! empty($parts['path'])) {
386
+            $parts['host'] = $parts['path'];
387
+            unset($parts['path']);
388
+        }
389
+
390
+        $this->applyParts($parts);
391
+
392
+        return $this;
393
+    }
394
+
395
+    /**
396
+     * Retrieve the host component of the URI.
397
+     * 
398
+     * @return string
399
+     */
400
+    public function getHost()
401
+    {
402
+        return $this->host;
403
+    }
404
+
405
+    /**
406
+     * Sets the host name to use.
407
+     * 
408
+     * @param  string  $str
409
+     * 
410
+     * @return $this
411
+     */
412
+    public function setHost(string $str)
413
+    {
414
+        $this->host = trim($str);
415
+
416
+        return $this->host;
417
+    }
418
+
419
+    /**
420
+     * Retrieve the port component of the URI.
421
+     * 
422
+     * @return int|null
423
+     */
424
+    public function getPort()
425
+    {
426
+        return $this->port;
427
+    }
428
+
429
+    /**
430
+     * Sets the port portion of the URI.
431
+     * 
432
+     * @param  int|null  $port  
433
+     * 
434
+     * @return string
435
+     */
436
+    public function setPort(int $port = null)
437
+    {
438
+        if (is_null($port)) {
439
+            return $this;
440
+        }
441
+
442
+        if ($port <= 0 || $port > 65355) {
443
+            throw HttpURIException::invalidPort($port);
444
+        }
445
+
446
+        $this->port = $port;
447
+
448
+        return $this->port;
449
+    }
450
+
451
+    /**
452
+     * Retrieve a URI fragment.
453
+     * 
454
+     * @return string
455
+     */
456
+    public function getFragment()
457
+    {
458
+        return is_null($this->fragment) ? '' : $this->fragment;
459
+    }
460
+
461
+    /**
462
+     * Sets the fragment portion of the URI.
463
+     * 
464
+     * @param  string  $str
465
+     * 
466
+     * @return $this
467
+     */
468
+    public function setFragment(string $str)
469
+    {
470
+        $this->fragment = trim($str, '# ');
471
+
472
+        return $this->fragment;
473
+    }
474
+
475
+    /**
476
+     * Saves our parts from a parse_url call.
477
+     * 
478
+     * @param  array  $parts
479
+     * 
480
+     * @return mixed
481
+     */
482
+    public function applyParts(array $paths)
483
+    {
484
+        if (isset($parts['scheme'])) {
485
+            $this->SetScheme(rtrim($parts['scheme'], ':/'));
486
+        } else {
487
+            $this->setScheme('http');
488
+        }
489
+
490
+        if ( ! empty($parts['host'])) {
491
+            $this->host = $parts['host'];
492
+        }
493
+
494
+        if (isset($parts['port'])) {
495
+            if ( ! is_null($parts['port'])) {
496
+                $this->port = $parts['port'];
497
+            }
498
+        }
499
+
500
+        if ( ! empty($parts['user'])) {
501
+            $this->user = $parts['user'];
502
+        }
503
+
504
+        if ( ! empty($parts['pass'])) {
505
+            $this->password = $parts['pass'];
506
+        }
507
+
508
+        if ( ! empty($parts['path'])) {
509
+            $this->path = $this->filterPath($parts['path']);
510
+        }
511
+
512
+        if ( ! empty($parts['fragment'])) {
513
+            $this->fragment = $parts['fragment'];
514
+        }
515
+
516
+        if ( ! empty($parts['path'])) {
517
+            $this->segments = explode('/', $parts['path'], '/');
518
+        }
519
+    }
520
+
521
+    /**
522
+     * Returns the URI string.
523
+     *
524
+     * @return string
525
+     */
526
+    public function __toString()
527
+    {
528
+        return (string) $this->getPath();
529
+    }
530 530
 }
Please login to merge, or discard this patch.