Passed
Push — 0.7.0 ( da5a73...a860c5 )
by Alexander
03:36 queued 10s
created
src/components/Core/Bootstrap/BootDetectEnvironment.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@
 block discarded – undo
113 113
     protected function createEnv($app)
114 114
     {
115 115
         return Dotenv::create(
116
-               Environment::getRepositoryCreator(),
117
-               $app->environmentPath(),
118
-               $app->environmentFile()
116
+                Environment::getRepositoryCreator(),
117
+                $app->environmentPath(),
118
+                $app->environmentFile()
119 119
         );
120 120
     }
121 121
 }
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Dotenv/Repository/AdapterRepository.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,14 +73,14 @@
 block discarded – undo
73 73
         return $this->readers->read($name);
74 74
     }
75 75
 
76
-     /**
77
-     * Set an environment variable.
78
-     * 
79
-     * @param  string  $name
80
-     * @param  string  $value
81
-     * 
82
-     * @return bool
83
-     */
76
+        /**
77
+         * Set an environment variable.
78
+         * 
79
+         * @param  string  $name
80
+         * @param  string  $value
81
+         * 
82
+         * @return bool
83
+         */
84 84
     public function set(string $name, string $value)
85 85
     {
86 86
         return $this->writers->write($name, $value);
Please login to merge, or discard this patch.
src/components/Dotenv/Loader/Loader.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@
 block discarded – undo
259 259
             $quote = $value[0];
260 260
 
261 261
             $regexPattern = sprintf(
262
-					'/^
262
+                    '/^
263 263
 					%1$s          # match a quote at the start of the value
264 264
 					(             # capturing sub-pattern used
265 265
 								  (?:          # we do not need to capture this
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@
 block discarded – undo
274 274
         if (strpos($value, '$') !== false) {
275 275
             $repository = $this->repository;
276 276
 
277
-            $value = preg_replace_callback('~\${([a-zA-Z0-9_]+)}~', function ($pattern) use ($repository) {
277
+            $value = preg_replace_callback('~\${([a-zA-Z0-9_]+)}~', function($pattern) use ($repository) {
278 278
                 $nestedVariable = $repository->get($pattern[1]);
279 279
 
280 280
                 if (is_null($nestedVariable)) {
Please login to merge, or discard this patch.
src/components/Contracts/Http/Lenevor.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@
 block discarded – undo
31 31
 interface Lenevor
32 32
 {
33 33
     /**
34
-	 * Initializes the framework, this can only be called once.
35
-	 * Launch the application.
36
-	 * 
37
-	 * @param  \Syscodes\http\Request  $request
38
-	 *
39
-	 * @return void
40
-	 * 
41
-	 * @uses   new \Syscodes\Http\Response
42
-	 */
43
- 	public function handle($request);
34
+     * Initializes the framework, this can only be called once.
35
+     * Launch the application.
36
+     * 
37
+     * @param  \Syscodes\http\Request  $request
38
+     *
39
+     * @return void
40
+     * 
41
+     * @uses   new \Syscodes\Http\Response
42
+     */
43
+        public function handle($request);
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Config/Configure.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -36,147 +36,147 @@
 block discarded – undo
36 36
  */
37 37
 class Configure implements ArrayAccess, ConfigureContract
38 38
 {
39
-	/**
40
-	 * Currently registered routes.
41
-	 * 
42
-	 * @var array $vars
43
-	 */
44
-	protected $vars = [];
39
+    /**
40
+     * Currently registered routes.
41
+     * 
42
+     * @var array $vars
43
+     */
44
+    protected $vars = [];
45 45
 
46
-	/**
47
-	 * Determine if the given configuration value exists.
48
-	 * 
49
-	 * @param  string  $key
50
-	 * 
51
-	 * @return bool
52
-	 */
53
-	public function has(string $key)
54
-	{
55
-		return Arr::has($this->vars, $key);
56
-	}
46
+    /**
47
+     * Determine if the given configuration value exists.
48
+     * 
49
+     * @param  string  $key
50
+     * 
51
+     * @return bool
52
+     */
53
+    public function has(string $key)
54
+    {
55
+        return Arr::has($this->vars, $key);
56
+    }
57 57
 
58
-	/**
59
-	 * Returns a (dot notated) config setting.
60
-	 *
61
-	 * @param  string  $key  The dot-notated key or array of keys
62
-	 * @param  mixed  $default  The default value
63
-	 *
64
-	 * @return mixed
65
-	 *
66
-	 * @uses   \Syscodes\Support\Arr
67
-	 */
68
-	public function get(string $key, $default = null)
69
-	{
70
-		$keys = explode('.', $key);
58
+    /**
59
+     * Returns a (dot notated) config setting.
60
+     *
61
+     * @param  string  $key  The dot-notated key or array of keys
62
+     * @param  mixed  $default  The default value
63
+     *
64
+     * @return mixed
65
+     *
66
+     * @uses   \Syscodes\Support\Arr
67
+     */
68
+    public function get(string $key, $default = null)
69
+    {
70
+        $keys = explode('.', $key);
71 71
 
72
-		if ( ! array_key_exists($file = current($keys), $this->vars)) {
73
-			foreach ([CON_PATH] as $paths) {
74
-				if (is_readable($path = $paths.$file.'.php')) {
75
-					$this->vars[$file] = require $path;
76
-				}				
77
-			}
78
-		} 
72
+        if ( ! array_key_exists($file = current($keys), $this->vars)) {
73
+            foreach ([CON_PATH] as $paths) {
74
+                if (is_readable($path = $paths.$file.'.php')) {
75
+                    $this->vars[$file] = require $path;
76
+                }				
77
+            }
78
+        } 
79 79
 
80
-		return Arr::get($this->vars, $key, $default);
81
-	}
80
+        return Arr::get($this->vars, $key, $default);
81
+    }
82 82
 
83
-	/**
84
-	 * Sets a value in the config array.
85
-	 *
86
-	 * @param  string  $key  The dot-notated key or array of keys
87
-	 * @param  mixed  $value  The default value
88
-	 *
89
-	 * @return mixed
90
-	 *
91
-	 * @uses   \Syscodes\Support\Arr
92
-	 */
93
-	public function set(string $key, $value)
94
-	{
95
-		strpos($key, '.') === false || $this->vars[$key] = $value;
83
+    /**
84
+     * Sets a value in the config array.
85
+     *
86
+     * @param  string  $key  The dot-notated key or array of keys
87
+     * @param  mixed  $value  The default value
88
+     *
89
+     * @return mixed
90
+     *
91
+     * @uses   \Syscodes\Support\Arr
92
+     */
93
+    public function set(string $key, $value)
94
+    {
95
+        strpos($key, '.') === false || $this->vars[$key] = $value;
96 96
 		
97
-		Arr::set($this->$vars, $key, $value);
98
-	}
97
+        Arr::set($this->$vars, $key, $value);
98
+    }
99 99
 
100
-	/**
101
-	 * Deletes a (dot notated) config item.
102
-	 *
103
-	 * @param  string  $key  A (dot notated) config key
104
-	 *
105
-	 * @return array|bool
106
-	 *
107
-	 * @uses   \Syscodes\Support\Arr
108
-	 */
109
-	public function erase(string $key)
110
-	{
111
-		if (isset($this->$vars[$key])) {
112
-			unset($this->$vars[$key]);
113
-		}
100
+    /**
101
+     * Deletes a (dot notated) config item.
102
+     *
103
+     * @param  string  $key  A (dot notated) config key
104
+     *
105
+     * @return array|bool
106
+     *
107
+     * @uses   \Syscodes\Support\Arr
108
+     */
109
+    public function erase(string $key)
110
+    {
111
+        if (isset($this->$vars[$key])) {
112
+            unset($this->$vars[$key]);
113
+        }
114 114
 		
115
-		Arr::erase($this->$vars, $key);
116
-	}
115
+        Arr::erase($this->$vars, $key);
116
+    }
117 117
 
118
-	/**
119
-	 * Get all of the configuration items for the application.
120
-	 * 
121
-	 * @return array
122
-	 */
123
-	public function all()
124
-	{
125
-		return $this->vars;
126
-	}
118
+    /**
119
+     * Get all of the configuration items for the application.
120
+     * 
121
+     * @return array
122
+     */
123
+    public function all()
124
+    {
125
+        return $this->vars;
126
+    }
127 127
 
128
-	/*
128
+    /*
129 129
     |-----------------------------------------------------------------
130 130
     | ArrayAccess Methods
131 131
     |-----------------------------------------------------------------
132 132
 	*/
133 133
 	
134
-	/**
135
-	 * Determine if the given configuration option exists.
136
-	 * 
137
-	 * @param  string  $key
138
-	 * 
139
-	 * @return bool
140
-	 */
141
-	public function offsetExists($key)
142
-	{
143
-		return $this->has($key);
144
-	}
134
+    /**
135
+     * Determine if the given configuration option exists.
136
+     * 
137
+     * @param  string  $key
138
+     * 
139
+     * @return bool
140
+     */
141
+    public function offsetExists($key)
142
+    {
143
+        return $this->has($key);
144
+    }
145 145
 	
146
-	/**
147
-	 * Get a configuration option.
148
-	 * 
149
-	 * @param  string  $key
150
-	 * 
151
-	 * @return mixed
152
-	 */
153
-	public function offsetGet($key)
154
-	{
155
-		return $this->get($key);
156
-	}
146
+    /**
147
+     * Get a configuration option.
148
+     * 
149
+     * @param  string  $key
150
+     * 
151
+     * @return mixed
152
+     */
153
+    public function offsetGet($key)
154
+    {
155
+        return $this->get($key);
156
+    }
157 157
 	
158
-	/**
159
-	 * Set a configuration option.
160
-	 * 
161
-	 * @param  string  $key
162
-	 * @param  mixed  $value
163
-	 * 
164
-	 * @return void
165
-	 */
166
-	public function offsetSet($key, $value)
167
-	{
168
-		$this->set($key, $value);
169
-	}
158
+    /**
159
+     * Set a configuration option.
160
+     * 
161
+     * @param  string  $key
162
+     * @param  mixed  $value
163
+     * 
164
+     * @return void
165
+     */
166
+    public function offsetSet($key, $value)
167
+    {
168
+        $this->set($key, $value);
169
+    }
170 170
 	
171
-	/**
172
-	 * Unset a configuration option.
173
-	 * 
174
-	 * @param  string  $key
175
-	 * 
176
-	 * @return void
177
-	 */
178
-	public function offsetUnset($key)
179
-	{
180
-		$this->set($key, null);
181
-	}
171
+    /**
172
+     * Unset a configuration option.
173
+     * 
174
+     * @param  string  $key
175
+     * 
176
+     * @return void
177
+     */
178
+    public function offsetUnset($key)
179
+    {
180
+        $this->set($key, null);
181
+    }
182 182
 }
183 183
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Container/Container.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
     protected function buildNotInstantiable(string $class)
247 247
     {
248 248
         if ( ! empty($this->buildStack)) {
249
-           $reset   = implode(', ', $this->buildStack);
249
+            $reset   = implode(', ', $this->buildStack);
250 250
 
251
-           $message = "Target [ {$class} ] is not instantiable while building [ {$reset} ]."; 
251
+            $message = "Target [ {$class} ] is not instantiable while building [ {$reset} ]."; 
252 252
         } else {
253 253
             $message = "Target [ {$class} ] is not instantiable.";
254 254
         }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
         array_pop($this->across);
681 681
 
682
-       return $this->resolveObject($id, $object);
682
+        return $this->resolveObject($id, $object);
683 683
     }
684 684
 
685 685
     /**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function getClosure($id, string $value)
186 186
     {
187
-        return function ($container, $parameters = []) use ($id, $value) {
187
+        return function($container, $parameters = []) use ($id, $value) {
188 188
             if ($id == $value) {
189 189
                 return $container->build($value);
190 190
             }
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      */
423 423
     public function factory($id)
424 424
     {
425
-        return function () use ($id) {
425
+        return function() use ($id) {
426 426
             return $this->make($id);
427 427
         };
428 428
     }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
      */
811 811
     public function bound($id)
812 812
     {
813
-        return isset($this->bindings[$id])  ||
813
+        return isset($this->bindings[$id]) ||
814 814
                isset($this->instances[$id]) ||
815 815
                $this->isAlias($id);
816 816
     }
Please login to merge, or discard this patch.
src/components/Pipeline/Pipeline.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
      */
152 152
     protected function call()
153 153
     {
154
-        return function ($stack, $pipe) {
155
-            return function ($passable) use ($stack, $pipe) {
154
+        return function($stack, $pipe) {
155
+            return function($passable) use ($stack, $pipe) {
156 156
                 try {
157 157
                     if (is_callable($pipe)) {
158 158
                         return $pipe($passable, $stack);
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function prepareDestination(Closure $destination)
207 207
     {
208
-        return function ($passable) use ($destination) {
208
+        return function($passable) use ($destination) {
209 209
             try {
210 210
                 return $destination($passable);
211
-            } catch(Throwable $e)  {
211
+            } catch (Throwable $e) {
212 212
                 return $this->handleException($passable, $e);
213 213
             }
214 214
         };
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
@@ -99,13 +99,13 @@
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-    * Redirects to another url. Sets the redirect header, sends the headers and exits.
103
-    * Can redirect via a Location header.
104
-    *
105
-    * @param  string  $url  The url
106
-    *
107
-    * @return $this
108
-    */
102
+     * Redirects to another url. Sets the redirect header, sends the headers and exits.
103
+     * Can redirect via a Location header.
104
+     *
105
+     * @param  string  $url  The url
106
+     *
107
+     * @return $this
108
+     */
109 109
     public function setTargetUrl($url)
110 110
     {
111 111
         if ('' === ($url ?? '')) {
Please login to merge, or discard this patch.
src/components/Http/Response.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
 			$replace = 0 === strcasecmp($name, 'Content-Type');
123 123
 
124 124
 			foreach ($values as $value) {
125
-				header($name.': '. $value, $replace, $this->status);
125
+				header($name.': '.$value, $replace, $this->status);
126 126
 			}
127 127
 		}
128 128
 
Please login to merge, or discard this patch.
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -39,297 +39,297 @@
 block discarded – undo
39 39
  */
40 40
 class Response extends Status 
41 41
 {
42
-	use ResponseTrait;
43
-
44
-	/**
45
-	 * Sets up the response with a content and a status code.
46
-	 *
47
-	 * @param  mixed  $content  The response content 
48
-	 * @param  int  $status  The response status  
49
-	 * @param  array  $headers  Array of HTTP headers for this response
50
-	 *
51
-	 * @return string
52
-	 */
53
-	public function __construct($content = '', int $status = 200, array $headers = [])
54
-	{
55
-		$this->setContent($content);
56
-		$this->setStatusCode($status);
42
+    use ResponseTrait;
43
+
44
+    /**
45
+     * Sets up the response with a content and a status code.
46
+     *
47
+     * @param  mixed  $content  The response content 
48
+     * @param  int  $status  The response status  
49
+     * @param  array  $headers  Array of HTTP headers for this response
50
+     *
51
+     * @return string
52
+     */
53
+    public function __construct($content = '', int $status = 200, array $headers = [])
54
+    {
55
+        $this->setContent($content);
56
+        $this->setStatusCode($status);
57 57
 		
58
-		$this->server  = new Server($_SERVER);
59
-		$this->headers = new Headers($headers);
60
-	}
61
-
62
-	/**
63
-	 * Creates an instance of the same response class for rendering contents to the content, 
64
-	 * status code and headers.
65
-	 *
66
-	 * @param  mixed  $content  The response content  
67
-	 * @param  int  $status  The HTTP response status for this response  
68
-	 * @param  array  $headers  Array of HTTP headers for this response
69
-	 *
70
-	 * @return static
71
-	 */
72
-	public static function render($content = '', $status = 200, $headers = [])
73
-	{
74
-		return new static($content, $status, $headers);
75
-	}
76
-
77
-	/**
78
-	 * Gets the current response content.
79
-	 * 
80
-	 * @return string
81
-	 */
82
-	public function getContent()
83
-	{
84
-		return $this->content;
85
-	}
86
-
87
-	/**
88
-	 * Gets the response status code.
89
-	 *
90
-	 * The status code is a 3-digit code to specify server response results to the browser.
91
-	 *
92
-	 * @return int
93
-	 *
94
-	 * @throws \BadMethodCallException
95
-	 */
96
-	public function getStatusCode()
97
-	{
98
-		if (empty($this->status)) {
99
-			throw new BadMethodCallException('HTTP Response is missing a status code.');
100
-		}
101
-
102
-		return $this->status;
103
-	}
104
-
105
-	/**
106
-	 * Sends the headers if they haven't already been sent. 
107
-	 * Returns whether they were sent or not.
108
-	 *
109
-	 * @return bool
110
-	 *
111
-	 * @uses   \Syscodes\Http\Http
112
-	 */
113
-	public function sendHeaders()
114
-	{
115
-		// Have the headers already been sent?
116
-		if (headers_sent()) {
117
-			return $this;
118
-		}
119
-
120
-		// Headers
121
-		foreach ($this->headers->allPreserveCase() as $name => $values) {
122
-			$replace = 0 === strcasecmp($name, 'Content-Type');
123
-
124
-			foreach ($values as $value) {
125
-				header($name.': '. $value, $replace, $this->status);
126
-			}
127
-		}
128
-
129
-		// Status
130
-		if ( ! empty($_SERVER['FCGI_SERVER_VERSION'])) {
131
-			// Send the protocol/status line first, FCGI servers need different status header
132
-			header(sprintf('Status: %s %s', $this->status, $this->statusText));
133
-		} else {
134
-			$this->protocol = (string) $this->server->get('SERVER_PROTOCOL') ?: 'HTTP/1.1';
135
-			header(sprintf('%s %s %s', $this->protocol, $this->status, $this->statusText), true, $this->status);
136
-		}
137
-
138
-		return $this;
139
-	}
140
-
141
-	/**
142
-	 * Sends content for the current web response.
143
-	 * 
144
-	 * @return $this
145
-	 */
146
-	public function sendContent()
147
-	{
148
-		echo $this->content;
149
-
150
-		return $this;
151
-	}
152
-
153
-	/**
154
-	 * Sends the response to the output buffer. Optionally, headers will be sent. 
155
-	 *
156
-	 * @param  bool  $sendHeader  Whether or not to send the defined HTTP headers
157
-	 *
158
-	 * @return $this
159
-	 */
160
-	public function send($sendHeader = false)
161
-	{
162
-		if ($sendHeader) {
163
-			$this->sendHeaders();
164
-		}
165
-
166
-		if (null !== $this->content) {
167
-			$this->sendContent();
168
-		}
169
-
170
-		return $this;
171
-	}
172
-
173
-	/**
174
-	 * Sends the content of the message to the browser.
175
-	 *
176
-	 * @param  mixed  $content  The response content
177
-	 *
178
-	 * @return $this
179
-	 */
180
-	public function setContent($content)
181
-	{
182
-		if ($content !== null && ! is_string($content) && ! is_numeric($content) && ! is_callable([$content, '__toString'])) {
183
-			throw new UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
184
-		}
185
-
186
-		if ($content instanceof JsonSerializable || is_array($content)) {
187
-			$this->header('Content-Type', 'application/json');
188
-
189
-			$content = json_encode($content);
190
-		} elseif ($content instanceof Renderable) {
191
-			$content = $content->render();
192
-		}
58
+        $this->server  = new Server($_SERVER);
59
+        $this->headers = new Headers($headers);
60
+    }
61
+
62
+    /**
63
+     * Creates an instance of the same response class for rendering contents to the content, 
64
+     * status code and headers.
65
+     *
66
+     * @param  mixed  $content  The response content  
67
+     * @param  int  $status  The HTTP response status for this response  
68
+     * @param  array  $headers  Array of HTTP headers for this response
69
+     *
70
+     * @return static
71
+     */
72
+    public static function render($content = '', $status = 200, $headers = [])
73
+    {
74
+        return new static($content, $status, $headers);
75
+    }
76
+
77
+    /**
78
+     * Gets the current response content.
79
+     * 
80
+     * @return string
81
+     */
82
+    public function getContent()
83
+    {
84
+        return $this->content;
85
+    }
86
+
87
+    /**
88
+     * Gets the response status code.
89
+     *
90
+     * The status code is a 3-digit code to specify server response results to the browser.
91
+     *
92
+     * @return int
93
+     *
94
+     * @throws \BadMethodCallException
95
+     */
96
+    public function getStatusCode()
97
+    {
98
+        if (empty($this->status)) {
99
+            throw new BadMethodCallException('HTTP Response is missing a status code.');
100
+        }
101
+
102
+        return $this->status;
103
+    }
104
+
105
+    /**
106
+     * Sends the headers if they haven't already been sent. 
107
+     * Returns whether they were sent or not.
108
+     *
109
+     * @return bool
110
+     *
111
+     * @uses   \Syscodes\Http\Http
112
+     */
113
+    public function sendHeaders()
114
+    {
115
+        // Have the headers already been sent?
116
+        if (headers_sent()) {
117
+            return $this;
118
+        }
119
+
120
+        // Headers
121
+        foreach ($this->headers->allPreserveCase() as $name => $values) {
122
+            $replace = 0 === strcasecmp($name, 'Content-Type');
123
+
124
+            foreach ($values as $value) {
125
+                header($name.': '. $value, $replace, $this->status);
126
+            }
127
+        }
128
+
129
+        // Status
130
+        if ( ! empty($_SERVER['FCGI_SERVER_VERSION'])) {
131
+            // Send the protocol/status line first, FCGI servers need different status header
132
+            header(sprintf('Status: %s %s', $this->status, $this->statusText));
133
+        } else {
134
+            $this->protocol = (string) $this->server->get('SERVER_PROTOCOL') ?: 'HTTP/1.1';
135
+            header(sprintf('%s %s %s', $this->protocol, $this->status, $this->statusText), true, $this->status);
136
+        }
137
+
138
+        return $this;
139
+    }
140
+
141
+    /**
142
+     * Sends content for the current web response.
143
+     * 
144
+     * @return $this
145
+     */
146
+    public function sendContent()
147
+    {
148
+        echo $this->content;
149
+
150
+        return $this;
151
+    }
152
+
153
+    /**
154
+     * Sends the response to the output buffer. Optionally, headers will be sent. 
155
+     *
156
+     * @param  bool  $sendHeader  Whether or not to send the defined HTTP headers
157
+     *
158
+     * @return $this
159
+     */
160
+    public function send($sendHeader = false)
161
+    {
162
+        if ($sendHeader) {
163
+            $this->sendHeaders();
164
+        }
165
+
166
+        if (null !== $this->content) {
167
+            $this->sendContent();
168
+        }
169
+
170
+        return $this;
171
+    }
172
+
173
+    /**
174
+     * Sends the content of the message to the browser.
175
+     *
176
+     * @param  mixed  $content  The response content
177
+     *
178
+     * @return $this
179
+     */
180
+    public function setContent($content)
181
+    {
182
+        if ($content !== null && ! is_string($content) && ! is_numeric($content) && ! is_callable([$content, '__toString'])) {
183
+            throw new UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
184
+        }
185
+
186
+        if ($content instanceof JsonSerializable || is_array($content)) {
187
+            $this->header('Content-Type', 'application/json');
188
+
189
+            $content = json_encode($content);
190
+        } elseif ($content instanceof Renderable) {
191
+            $content = $content->render();
192
+        }
193 193
 		
194
-		$this->content = $content ?? '';
195
-
196
-		return $this;
197
-	}
198
-
199
-	/**
200
-	 * Prepares the Response before it is sent to the client.
201
-	 * 
202
-	 * @param  \Syscodes\Http\Request  $request
203
-	 * 
204
-	 * @return $this
205
-	 */
206
-	public function prepare($request)
207
-	{
208
-		$headers = $this->headers;
209
-
210
-		if ($this->isInformational() || $this->isEmpty()) {
211
-			$this->setContent(null);
212
-			$headers->remove('Content-Type');
213
-			$headers->remove('Content-Length');
214
-		}
215
-
216
-		return $this;
217
-	}
218
-
219
-	/**
220
-	* Sets the response status code.
221
-	*
222
-	* @param  int  $code  The status code
223
-	* @param  string|null  $text  The status text
224
-	*
225
-	* @return $this
226
-	*
227
-	* @throws \InvalidArgumentException
228
-	*/
229
-	public function setStatusCode(int $code, $text = null)
230
-	{
231
-		$this->status = $code; 
232
-
233
-		// Valid range?
234
-		if ($this->isInvalid()) {
235
-			throw new InvalidArgumentException(__('response.statusCodeNotValid', ['code' => $code]));			
236
-		}
237
-
238
-		// Check if you have an accepted status code if not shows to a message of unknown status
239
-		if (null === $text) {
240
-			$this->statusText = isset($this->statusCodes[$code]) ? $this->statusCodes[$code] : __('response.UnknownStatus');
241
-
242
-			return $this;
243
-		}
244
-
245
-		if (false === $text) {
246
-			$this->statusText = '';
247
-
248
-			return $this;
249
-		}
250
-
251
-		$this->statusText = $text;
252
-
253
-		return $this;
254
-	}
255
-
256
-	/**
257
-	 * Is response invalid?
258
-	 * 
259
-	 * @final
260
-	 * 
261
-	 * @return void
262
-	 */
263
-	public function isInvalid(): bool
264
-	{
265
-		return $this->status < 100 || $this->status >= 600;
266
-	}
267
-
268
-	/**
269
-	 * Is response informative?
270
-	 * 
271
-	 * @final
272
-	 * 
273
-	 * @return void
274
-	 */
275
-	public function isInformational()
276
-	{
277
-		return $this->status >= 100 && $this->status < 200;
278
-	}
194
+        $this->content = $content ?? '';
195
+
196
+        return $this;
197
+    }
198
+
199
+    /**
200
+     * Prepares the Response before it is sent to the client.
201
+     * 
202
+     * @param  \Syscodes\Http\Request  $request
203
+     * 
204
+     * @return $this
205
+     */
206
+    public function prepare($request)
207
+    {
208
+        $headers = $this->headers;
209
+
210
+        if ($this->isInformational() || $this->isEmpty()) {
211
+            $this->setContent(null);
212
+            $headers->remove('Content-Type');
213
+            $headers->remove('Content-Length');
214
+        }
215
+
216
+        return $this;
217
+    }
218
+
219
+    /**
220
+     * Sets the response status code.
221
+     *
222
+     * @param  int  $code  The status code
223
+     * @param  string|null  $text  The status text
224
+     *
225
+     * @return $this
226
+     *
227
+     * @throws \InvalidArgumentException
228
+     */
229
+    public function setStatusCode(int $code, $text = null)
230
+    {
231
+        $this->status = $code; 
232
+
233
+        // Valid range?
234
+        if ($this->isInvalid()) {
235
+            throw new InvalidArgumentException(__('response.statusCodeNotValid', ['code' => $code]));			
236
+        }
237
+
238
+        // Check if you have an accepted status code if not shows to a message of unknown status
239
+        if (null === $text) {
240
+            $this->statusText = isset($this->statusCodes[$code]) ? $this->statusCodes[$code] : __('response.UnknownStatus');
241
+
242
+            return $this;
243
+        }
244
+
245
+        if (false === $text) {
246
+            $this->statusText = '';
247
+
248
+            return $this;
249
+        }
250
+
251
+        $this->statusText = $text;
252
+
253
+        return $this;
254
+    }
255
+
256
+    /**
257
+     * Is response invalid?
258
+     * 
259
+     * @final
260
+     * 
261
+     * @return void
262
+     */
263
+    public function isInvalid(): bool
264
+    {
265
+        return $this->status < 100 || $this->status >= 600;
266
+    }
267
+
268
+    /**
269
+     * Is response informative?
270
+     * 
271
+     * @final
272
+     * 
273
+     * @return void
274
+     */
275
+    public function isInformational()
276
+    {
277
+        return $this->status >= 100 && $this->status < 200;
278
+    }
279 279
 	
280
-	/**
281
-	 * Is the response a redirect?
282
-	 * 
283
-	 * @final
284
-	 * 
285
-	 * @return void
286
-	 */
287
-	public function isRedirection()
288
-	{
289
-		return $this->status >= 300 && $this->status < 400;
290
-	}
280
+    /**
281
+     * Is the response a redirect?
282
+     * 
283
+     * @final
284
+     * 
285
+     * @return void
286
+     */
287
+    public function isRedirection()
288
+    {
289
+        return $this->status >= 300 && $this->status < 400;
290
+    }
291 291
 	
292
-	/**
293
-	 * Is the response empty?
294
-	 * 
295
-	 * @final
296
-	 * 
297
-	 * @return void
298
-	 */
299
-	public function isEmpty()
300
-	{
301
-		return in_array($this->status, [204, 304]);
302
-	}
292
+    /**
293
+     * Is the response empty?
294
+     * 
295
+     * @final
296
+     * 
297
+     * @return void
298
+     */
299
+    public function isEmpty()
300
+    {
301
+        return in_array($this->status, [204, 304]);
302
+    }
303 303
 	
304
-	/**
305
-	 * Is the response a redirect of some form?
306
-	 * 
307
-	 * @return bool
308
-	 */
309
-	public function isRedirect()
310
-	{
311
-		return in_array($this->status, [301, 302, 303, 307, 308]);
312
-	}
304
+    /**
305
+     * Is the response a redirect of some form?
306
+     * 
307
+     * @return bool
308
+     */
309
+    public function isRedirect()
310
+    {
311
+        return in_array($this->status, [301, 302, 303, 307, 308]);
312
+    }
313 313
 	
314
-	/**
315
-	 * Returns the Response as an HTTP string.
316
-	 * 
317
-	 * @return string
318
-	 */
319
-	public function __toString()
320
-	{
321
-		return sprintf('%s %s %s', $this->protocol, $this->status, $this->statusText)."\r\n".
322
-			$this->headers."\r\n".
323
-			$this->getContent();
324
-	}
314
+    /**
315
+     * Returns the Response as an HTTP string.
316
+     * 
317
+     * @return string
318
+     */
319
+    public function __toString()
320
+    {
321
+        return sprintf('%s %s %s', $this->protocol, $this->status, $this->statusText)."\r\n".
322
+            $this->headers."\r\n".
323
+            $this->getContent();
324
+    }
325 325
 	
326
-	/**
327
-	 * Clone the current Response instance.
328
-	 * 
329
-	 * @return void
330
-	 */
331
-	public function __clone()
332
-	{
333
-		$this->headers = clone $this->headers;
334
-	}
326
+    /**
327
+     * Clone the current Response instance.
328
+     * 
329
+     * @return void
330
+     */
331
+    public function __clone()
332
+    {
333
+        $this->headers = clone $this->headers;
334
+    }
335 335
 }
336 336
\ No newline at end of file
Please login to merge, or discard this patch.