Passed
Push — 0.7.0 ( 9eca06...f20096 )
by Alexander
03:01 queued 10s
created
src/components/Core/Http/Lenevor.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -39,172 +39,172 @@
 block discarded – undo
39 39
  */
40 40
 class Lenevor implements LenevorContract
41 41
 {
42
-	/**
43
-	 * The application implementation.
44
-	 * 
45
-	 * @var \Syscodes\Contracts\Core\Application $app
46
-	 */
47
-	protected $app;
42
+    /**
43
+     * The application implementation.
44
+     * 
45
+     * @var \Syscodes\Contracts\Core\Application $app
46
+     */
47
+    protected $app;
48 48
 	
49
-	/**
50
-	 * The bootstrap classes for the application.
51
-	 * 
52
-	 * @var array $bootstrappers
53
-	 */
54
-	protected $bootstrappers = [
55
-		\Syscodes\Core\Bootstrap\BootDetectEnvironment::class,
56
-		\Syscodes\Core\Bootstrap\BootConfiguration::class,
57
-		\Syscodes\Core\Bootstrap\BootHandleExceptions::class,
58
-		\Syscodes\Core\Bootstrap\BootRegisterFacades::class,
59
-		\Syscodes\Core\Bootstrap\BootRegisterProviders::class,
60
-		\Syscodes\Core\Bootstrap\BootProviders::class,
61
-	];
49
+    /**
50
+     * The bootstrap classes for the application.
51
+     * 
52
+     * @var array $bootstrappers
53
+     */
54
+    protected $bootstrappers = [
55
+        \Syscodes\Core\Bootstrap\BootDetectEnvironment::class,
56
+        \Syscodes\Core\Bootstrap\BootConfiguration::class,
57
+        \Syscodes\Core\Bootstrap\BootHandleExceptions::class,
58
+        \Syscodes\Core\Bootstrap\BootRegisterFacades::class,
59
+        \Syscodes\Core\Bootstrap\BootRegisterProviders::class,
60
+        \Syscodes\Core\Bootstrap\BootProviders::class,
61
+    ];
62 62
 	
63
-	/**
64
-	 * Activate the console mode.
65
-	 * 
66
-	 * @var bool $isCli
67
-	 */
68
-	protected $isCli = false;
69
-
70
-	/**
71
-	 * The router instance.
72
-	 * 
73
-	 * @var \Syscodes\Routing\Router $router
74
-	 */
75
-	protected $router;
76
-
77
-	/**
78
-	 * Total app execution time.
79
-	 * 
80
-	 * @var float $totalTime
81
-	 */
82
-	protected $totalTime;
83
-
84
-	/**
85
-	 * Constructor. Lenevor class instance.
86
-	 * 
87
-	 * @param  \Syscodes\Contracts\Core\Application  $app
88
-	 * @param  \Syscodes\Routing\Router  $router
89
-	 * 
90
-	 * @return void
91
-	 */
92
-	public function __construct(Application $app, Router $router)
93
-	{
94
-		$this->app    = $app;
95
-		$this->router = $router;
96
-	}
63
+    /**
64
+     * Activate the console mode.
65
+     * 
66
+     * @var bool $isCli
67
+     */
68
+    protected $isCli = false;
69
+
70
+    /**
71
+     * The router instance.
72
+     * 
73
+     * @var \Syscodes\Routing\Router $router
74
+     */
75
+    protected $router;
76
+
77
+    /**
78
+     * Total app execution time.
79
+     * 
80
+     * @var float $totalTime
81
+     */
82
+    protected $totalTime;
83
+
84
+    /**
85
+     * Constructor. Lenevor class instance.
86
+     * 
87
+     * @param  \Syscodes\Contracts\Core\Application  $app
88
+     * @param  \Syscodes\Routing\Router  $router
89
+     * 
90
+     * @return void
91
+     */
92
+    public function __construct(Application $app, Router $router)
93
+    {
94
+        $this->app    = $app;
95
+        $this->router = $router;
96
+    }
97 97
 	
98
-	/** 
99
-	 * Initialize CLI command.
100
-	 * 
101
-	 * @return bool
102
-	 */
103
-	public function initCli()
104
-	{
105
-		return $this->isCli = (new Http)->isCli();
106
-	}
98
+    /** 
99
+     * Initialize CLI command.
100
+     * 
101
+     * @return bool
102
+     */
103
+    public function initCli()
104
+    {
105
+        return $this->isCli = (new Http)->isCli();
106
+    }
107 107
 	 
108
-	/**
109
-	 * Initializes the framework, this can only be called once.
110
-	 * Launch the application.
111
-	 * 
112
-	 * @param  \Syscodes\http\Request  $request
113
-	 *
114
-	 * @return \Syscodes\Http\Response
115
-	 */
116
-	public function handle($request)
117
-	{
118
-		try {
119
-			$response = $this->sendRequestThroughRouter($request);
120
-		} catch (Throwable $e) {
121
-			$this->reportException($e);
122
-
123
-			$response = $this->renderException($request, $e);
124
-		}		
125
-
126
-		return $response;
127
-	}
128
-
129
-	/**
130
-	 * Send the given request through the router.
131
-	 * 
132
-	 * @param  \Syscodes\Http\Request  $request
133
-	 * 
134
-	 * @return \Syscodes\Http\Response
135
-	 */
136
-	protected function sendRequestThroughRouter($request)
137
-	{
138
-		$this->app->instance('request', $request);  
139
-
140
-		Facade::clearResolvedInstance('request');
141
-
142
-		// Load configuration system
143
-		$this->bootstrap();
144
-
145
-		return (new Pipeline($this->app))
146
-				->send($request)
147
-				->then($this->dispatchToRouter());
148
-	}
149
-
150
-	/**
151
-	 * Bootstrap the application for HTTP requests.
152
-	 * 
153
-	 * @return void
154
-	 */
155
-	protected function bootstrap()
156
-	{		
157
-		if ( ! $this->app->hasBeenBootstrapped()) {
158
-			$this->app->bootstrapWith($this->bootstrappers());
159
-		}
160
-	}
161
-
162
-	/**
163
-	 * Get the bootstrap classes for the application.
164
-	 * 
165
-	 * @return array
166
-	 */
167
-	protected function bootstrappers()
168
-	{
169
-		return $this->bootstrappers;
170
-	}
171
-
172
-	/**
173
-	 * Get the dispatcher of routes.
174
-	 * 	  
175
-	 * @return \Closure
176
- 	 */
177
-	protected function dispatchToRouter()
178
-	{
179
-		return function ($request) {
180
-			$this->app->instance('request', $request);
181
-
182
-			return $this->router->dispatch($request);
183
-		};
184
-	}
185
-
186
-	/**
187
-	 * Report the exception to the exception handler.
188
-	 * 
189
-	 * @param  \Throwable  $e
190
-	 * 
191
-	 * @return void
192
-	 */
193
-	protected function reportException(Throwable $e)
194
-	{
195
-		return $this->app[ExceptionHandler::class]->report($e);
196
-	}
108
+    /**
109
+     * Initializes the framework, this can only be called once.
110
+     * Launch the application.
111
+     * 
112
+     * @param  \Syscodes\http\Request  $request
113
+     *
114
+     * @return \Syscodes\Http\Response
115
+     */
116
+    public function handle($request)
117
+    {
118
+        try {
119
+            $response = $this->sendRequestThroughRouter($request);
120
+        } catch (Throwable $e) {
121
+            $this->reportException($e);
122
+
123
+            $response = $this->renderException($request, $e);
124
+        }		
125
+
126
+        return $response;
127
+    }
128
+
129
+    /**
130
+     * Send the given request through the router.
131
+     * 
132
+     * @param  \Syscodes\Http\Request  $request
133
+     * 
134
+     * @return \Syscodes\Http\Response
135
+     */
136
+    protected function sendRequestThroughRouter($request)
137
+    {
138
+        $this->app->instance('request', $request);  
139
+
140
+        Facade::clearResolvedInstance('request');
141
+
142
+        // Load configuration system
143
+        $this->bootstrap();
144
+
145
+        return (new Pipeline($this->app))
146
+                ->send($request)
147
+                ->then($this->dispatchToRouter());
148
+    }
149
+
150
+    /**
151
+     * Bootstrap the application for HTTP requests.
152
+     * 
153
+     * @return void
154
+     */
155
+    protected function bootstrap()
156
+    {		
157
+        if ( ! $this->app->hasBeenBootstrapped()) {
158
+            $this->app->bootstrapWith($this->bootstrappers());
159
+        }
160
+    }
161
+
162
+    /**
163
+     * Get the bootstrap classes for the application.
164
+     * 
165
+     * @return array
166
+     */
167
+    protected function bootstrappers()
168
+    {
169
+        return $this->bootstrappers;
170
+    }
171
+
172
+    /**
173
+     * Get the dispatcher of routes.
174
+     * 	  
175
+     * @return \Closure
176
+     */
177
+    protected function dispatchToRouter()
178
+    {
179
+        return function ($request) {
180
+            $this->app->instance('request', $request);
181
+
182
+            return $this->router->dispatch($request);
183
+        };
184
+    }
185
+
186
+    /**
187
+     * Report the exception to the exception handler.
188
+     * 
189
+     * @param  \Throwable  $e
190
+     * 
191
+     * @return void
192
+     */
193
+    protected function reportException(Throwable $e)
194
+    {
195
+        return $this->app[ExceptionHandler::class]->report($e);
196
+    }
197 197
 	
198
-	/**
199
-	 * Render the exception to a response.
200
-	 * 
201
-	 * @param  \Syscodes\Http\Request  $request
202
-	 * @param  \Throwable  $e
203
-	 * 
204
-	 * @return \Syscodes\Http\Response
205
-	 */
206
-	protected function renderException($request, Throwable $e)
207
-	{
208
-		return $this->app[ExceptionHandler::class]->render($request, $e);
209
-	}
210
- }
211 198
\ No newline at end of file
199
+    /**
200
+     * Render the exception to a response.
201
+     * 
202
+     * @param  \Syscodes\Http\Request  $request
203
+     * @param  \Throwable  $e
204
+     * 
205
+     * @return \Syscodes\Http\Response
206
+     */
207
+    protected function renderException($request, Throwable $e)
208
+    {
209
+        return $this->app[ExceptionHandler::class]->render($request, $e);
210
+    }
211
+    }
212 212
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Console/Cli.php 2 patches
Indentation   +695 added lines, -695 removed lines patch added patch discarded remove patch
@@ -34,710 +34,710 @@
 block discarded – undo
34 34
  */
35 35
 class Cli
36 36
 {
37
-	/**
38
- 	 * Background color identifier.
39
- 	 *
40
- 	 * @var array $backgroundColors
41
- 	 */
42
- 	protected static $backgroundColors = [
43
- 		'black'      => '40',
44
- 		'red'        => '41',
45
- 		'green'      => '42',
46
- 		'yellow'     => '43',
47
- 		'blue'       => '44',
48
- 		'magenta'    => '45',
49
- 		'cyan'       => '46',
50
- 		'light_gray' => '47'
51
- 	];
52
-
53
-	/**
54
-	 * Foreground color identifier.
55
- 	 *
56
- 	 * @var array $foregroundColors
57
-	 */
58
-	protected static $foregroundColors = [
59
-		'black'         => '0;30',
60
-		'dark_gray'     => '1;30',
61
-		'blue'          => '0;34',
62
-		'dark_blue'     => '1;34',
63
-		'light_blue'    => '1;34',
64
-		'green'         => '0;32',
65
-		'light_green'   => '1;32',
66
-		'cyan'          => '0;36', 
67
-		'light_cyan'    => '1;36',
68
-		'red'           => '0;31',
69
-		'light_red'     => '1;31',
70
-		'purple'        => '0;35',
71
-		'light_purple'  => '1;35',
72
-		'light_yellow'  => '0;33',
73
-		'yellow'        => '1;33',
74
-		'light_gray'    => '0;37',
75
-		'white'         => '1;37'
76
- 	];
77
-
78
-	/**
79
-	 * Indicates that you do not use any color for foreground or background.
80
-	 *
81
-	 * @var bool $noColor
82
-	 */
83
-	public static $noColor = false;
84
-
85
-	/**
86
-	 * String of arguments to be used in console.
87
-	 *
88
-	 * @var array $options
89
-	 */
90
-	protected static $options = [];
91
-
92
-	/**
93
-	 * Readline Support for command line.
94
-	 *
95
-	 * @var bool $readlineSupport
96
-	 */
97
-	public static $readlineSupport = false;
98
-
99
-	/**
100
-	 * List of array segments.
101
-	 *
102
-	 * @var array $segments
103
-	 */
104
-	protected static $segments = [];
105
-
106
- 	/**
107
- 	 * The standar STDERR is where the application writes its error messages.
108
- 	 *
109
- 	 * @var string $stderr 
110
- 	 */
111
- 	protected static $stderr;
112
-
113
- 	/**
114
- 	 * The estandar STDOUT is where the application records its output messages.
115
- 	 *
116
- 	 * @var string $stdout
117
- 	 */
118
- 	protected static $stdout;
119
-
120
- 	/**
121
-	 * Message that tells the user that he is waiting to receive an order.
122
-	 *
123
-	 * @var string $waitMsg
124
-	 */
125
-	public static $waitMsg = 'Press any key to continue...';
126
-
127
-	/**
128
-	 * Static constructor. Parses all the CLI params.
129
-	 * 
130
-	 * @return string
131
-	 * 
132
-	 * @uses   \Syscodes\Contracts\Core\Lenevor
133
-	 * 
134
-	 * @throws \Exception
135
-	 */
136
- 	public static function initialize(Lenevor $core)
137
- 	{
138
- 		if ( ! $core->initCli()) {
139
-			throw new Exception('Cli class cannot be used outside of the command line');
140
- 		}
141
-
142
- 		// Readline is an extension for PHP that makes interactive the command console
143
- 		static::$readlineSupport = extension_loaded('readline');
144
-
145
- 		// clear segments & options to keep testing clean
146
- 		static::$options  = [];
147
- 		static::$segments = [];
148
-
149
- 		static::parseCommandLine();
150
-
151
- 		// Writes its error messages
152
- 		static::$stderr = STDERR;
153
-
154
- 		// Records its output messages
155
- 		static::$stdout = STDOUT;
156
- 	}
157
-
158
- 	/**
159
- 	 * Beeps a certain number of times.
160
-	 *
161
-	 * @param  int  $num  The number of times to beep
162
-	 *
163
- 	 * @return int
164
- 	 */
165
- 	public static function bell(int $num = 1)
166
- 	{
167
- 		echo str_repeat("\x07", $num);
168
- 	}
169
-
170
- 	/**
171
- 	 * Clears the screen of output.
172
- 	 *
173
- 	 * @return void
174
- 	 */
175
- 	public static function clearScreen()
176
- 	{
177
- 		static::isWindows() 
178
-
179
- 			// Windows doesn't work for this, but their terminal is tiny so shove this in
180
- 			? static::newLine(40)
181
-
182
- 			// Anything with a flair of Unix will handle these magic characters
183
- 			: fwrite(static::$stdout, chr(27)."[H".chr(27)."[2J");
184
- 	}
185
-
186
- 	/**
187
- 	 * Returns the given text with the correct color codes for a foreground and
188
-	 * optionally a background color.
189
- 	 *
190
- 	 * @param  string  $text  The text to color
191
- 	 * @param  string  $foreground  The foreground color
192
- 	 * @param  string  $background  The background color
193
- 	 * @param  string  $format  Other formatting to apply. Currently only 'underline' is understood
194
- 	 *
195
- 	 * @return string  The color coded string
196
- 	 *
197
- 	 * @throws \Syscodes\Core\Exceptions\LenevorException
198
- 	 */
199
- 	public static function color(string $text, string $foreground, string $background = null, string $format = null)
200
- 	{
201
- 		if (static::$noColor)
202
- 		{
203
- 			return $text;
204
- 		}
205
-
206
- 		if ( ! Arr::exists(static::$foregroundColors, $foreground)) {
207
- 			throw new LenevorException(static::error("Invalid CLI foreground color: {$foreground}."));
208
- 		}
209
-
210
- 		if ( $background !== null && ! Arr::exists(static::$backgroundColors, $background)) {
211
- 			throw new LenevorException(static::error("Invalid CLI background color: {$background}."));
212
- 		}
213
-
214
- 		$string = "\033[".static::$foregroundColors[$foreground]."m";
215
-
216
- 		if ($background !== null) {
217
- 			$string .= "\033[".static::$backgroundColors[$background]."m";
218
- 		}
219
-
220
- 		if ($format === 'underline') {
221
- 			$string .= "\033[4m";
222
- 		}
223
-
224
- 		$string .= $text."\033[0m";
225
-
226
- 		return $string;
227
- 	}
228
-
229
- 	/**
230
- 	 * Get the number of characters in a string.
231
- 	 *
232
- 	 * @param  string  $string
233
- 	 *
234
- 	 * @return int
235
- 	 */
236
- 	public static function strlen(?string $string)
237
- 	{
238
- 		if (is_null($string)) {
239
- 			return 0;
240
- 		}
241
-
242
- 		foreach (static::$foregroundColors as $color) {
243
- 			$string = strtr($string, ["\033[".$color.'m' => '']);
244
- 		}
245
-
246
- 		foreach (static::$backgroundColors as $color) {
247
- 			$string = strtr($string, ["\033[".$color.'m' => '']);
248
- 		}
249
-
250
- 		$string = strtr($string, ["\033[4m" => '', "\033[0m" => '']);
251
-
252
- 		return mb_strlen($string);
253
- 	}
254
-
255
- 	/**
256
- 	 * Outputs an error to the CLI using STDERR instead of STDOUT.
257
- 	 *
258
- 	 * @param  string|array  $text  The text to output, or array of errors
259
- 	 * @param  string  $foreground  The foreground color
260
- 	 * @param  string|null  $background  the background color
261
- 	 *
262
- 	 * @return string
263
- 	 */
264
- 	public static function error(string $text = '', string $foreground = 'light_red', string $background = null)
265
- 	{
266
-		if (is_array($text)) {
267
-			$text = implode(PHP_EOL, $text);
268
-		}
37
+    /**
38
+     * Background color identifier.
39
+     *
40
+     * @var array $backgroundColors
41
+     */
42
+        protected static $backgroundColors = [
43
+            'black'      => '40',
44
+            'red'        => '41',
45
+            'green'      => '42',
46
+            'yellow'     => '43',
47
+            'blue'       => '44',
48
+            'magenta'    => '45',
49
+            'cyan'       => '46',
50
+            'light_gray' => '47'
51
+        ];
52
+
53
+    /**
54
+     * Foreground color identifier.
55
+     *
56
+     * @var array $foregroundColors
57
+     */
58
+    protected static $foregroundColors = [
59
+        'black'         => '0;30',
60
+        'dark_gray'     => '1;30',
61
+        'blue'          => '0;34',
62
+        'dark_blue'     => '1;34',
63
+        'light_blue'    => '1;34',
64
+        'green'         => '0;32',
65
+        'light_green'   => '1;32',
66
+        'cyan'          => '0;36', 
67
+        'light_cyan'    => '1;36',
68
+        'red'           => '0;31',
69
+        'light_red'     => '1;31',
70
+        'purple'        => '0;35',
71
+        'light_purple'  => '1;35',
72
+        'light_yellow'  => '0;33',
73
+        'yellow'        => '1;33',
74
+        'light_gray'    => '0;37',
75
+        'white'         => '1;37'
76
+        ];
77
+
78
+    /**
79
+     * Indicates that you do not use any color for foreground or background.
80
+     *
81
+     * @var bool $noColor
82
+     */
83
+    public static $noColor = false;
84
+
85
+    /**
86
+     * String of arguments to be used in console.
87
+     *
88
+     * @var array $options
89
+     */
90
+    protected static $options = [];
91
+
92
+    /**
93
+     * Readline Support for command line.
94
+     *
95
+     * @var bool $readlineSupport
96
+     */
97
+    public static $readlineSupport = false;
98
+
99
+    /**
100
+     * List of array segments.
101
+     *
102
+     * @var array $segments
103
+     */
104
+    protected static $segments = [];
105
+
106
+        /**
107
+         * The standar STDERR is where the application writes its error messages.
108
+         *
109
+         * @var string $stderr 
110
+         */
111
+        protected static $stderr;
112
+
113
+        /**
114
+         * The estandar STDOUT is where the application records its output messages.
115
+         *
116
+         * @var string $stdout
117
+         */
118
+        protected static $stdout;
119
+
120
+        /**
121
+         * Message that tells the user that he is waiting to receive an order.
122
+         *
123
+         * @var string $waitMsg
124
+         */
125
+    public static $waitMsg = 'Press any key to continue...';
126
+
127
+    /**
128
+     * Static constructor. Parses all the CLI params.
129
+     * 
130
+     * @return string
131
+     * 
132
+     * @uses   \Syscodes\Contracts\Core\Lenevor
133
+     * 
134
+     * @throws \Exception
135
+     */
136
+        public static function initialize(Lenevor $core)
137
+        {
138
+            if ( ! $core->initCli()) {
139
+            throw new Exception('Cli class cannot be used outside of the command line');
140
+            }
141
+
142
+            // Readline is an extension for PHP that makes interactive the command console
143
+            static::$readlineSupport = extension_loaded('readline');
144
+
145
+            // clear segments & options to keep testing clean
146
+            static::$options  = [];
147
+            static::$segments = [];
148
+
149
+            static::parseCommandLine();
150
+
151
+            // Writes its error messages
152
+            static::$stderr = STDERR;
153
+
154
+            // Records its output messages
155
+            static::$stdout = STDOUT;
156
+        }
157
+
158
+        /**
159
+         * Beeps a certain number of times.
160
+         *
161
+         * @param  int  $num  The number of times to beep
162
+         *
163
+         * @return int
164
+         */
165
+        public static function bell(int $num = 1)
166
+        {
167
+            echo str_repeat("\x07", $num);
168
+        }
169
+
170
+        /**
171
+         * Clears the screen of output.
172
+         *
173
+         * @return void
174
+         */
175
+        public static function clearScreen()
176
+        {
177
+            static::isWindows() 
178
+
179
+                // Windows doesn't work for this, but their terminal is tiny so shove this in
180
+             ? static::newLine(40)
181
+
182
+                // Anything with a flair of Unix will handle these magic characters
183
+             : fwrite(static::$stdout, chr(27)."[H".chr(27)."[2J");
184
+        }
185
+
186
+        /**
187
+         * Returns the given text with the correct color codes for a foreground and
188
+         * optionally a background color.
189
+         *
190
+         * @param  string  $text  The text to color
191
+         * @param  string  $foreground  The foreground color
192
+         * @param  string  $background  The background color
193
+         * @param  string  $format  Other formatting to apply. Currently only 'underline' is understood
194
+         *
195
+         * @return string  The color coded string
196
+         *
197
+         * @throws \Syscodes\Core\Exceptions\LenevorException
198
+         */
199
+        public static function color(string $text, string $foreground, string $background = null, string $format = null)
200
+        {
201
+            if (static::$noColor)
202
+            {
203
+                return $text;
204
+            }
205
+
206
+            if ( ! Arr::exists(static::$foregroundColors, $foreground)) {
207
+                throw new LenevorException(static::error("Invalid CLI foreground color: {$foreground}."));
208
+            }
209
+
210
+            if ( $background !== null && ! Arr::exists(static::$backgroundColors, $background)) {
211
+                throw new LenevorException(static::error("Invalid CLI background color: {$background}."));
212
+            }
213
+
214
+            $string = "\033[".static::$foregroundColors[$foreground]."m";
215
+
216
+            if ($background !== null) {
217
+                $string .= "\033[".static::$backgroundColors[$background]."m";
218
+            }
219
+
220
+            if ($format === 'underline') {
221
+                $string .= "\033[4m";
222
+            }
223
+
224
+            $string .= $text."\033[0m";
225
+
226
+            return $string;
227
+        }
228
+
229
+        /**
230
+         * Get the number of characters in a string.
231
+         *
232
+         * @param  string  $string
233
+         *
234
+         * @return int
235
+         */
236
+        public static function strlen(?string $string)
237
+        {
238
+            if (is_null($string)) {
239
+                return 0;
240
+            }
241
+
242
+            foreach (static::$foregroundColors as $color) {
243
+                $string = strtr($string, ["\033[".$color.'m' => '']);
244
+            }
245
+
246
+            foreach (static::$backgroundColors as $color) {
247
+                $string = strtr($string, ["\033[".$color.'m' => '']);
248
+            }
249
+
250
+            $string = strtr($string, ["\033[4m" => '', "\033[0m" => '']);
251
+
252
+            return mb_strlen($string);
253
+        }
254
+
255
+        /**
256
+         * Outputs an error to the CLI using STDERR instead of STDOUT.
257
+         *
258
+         * @param  string|array  $text  The text to output, or array of errors
259
+         * @param  string  $foreground  The foreground color
260
+         * @param  string|null  $background  the background color
261
+         *
262
+         * @return string
263
+         */
264
+        public static function error(string $text = '', string $foreground = 'light_red', string $background = null)
265
+        {
266
+        if (is_array($text)) {
267
+            $text = implode(PHP_EOL, $text);
268
+        }
269 269
 		
270
-		if ($foreground || $background) {
271
-			$text = static::color($text, $foreground, $background);
272
-		}
270
+        if ($foreground || $background) {
271
+            $text = static::color($text, $foreground, $background);
272
+        }
273 273
 		
274
-		fwrite(static::$stderr, $text.PHP_EOL);
275
-	}
276
-
277
-	/**
278
-	 * Attempts to determine the width of the viewable CLI window.
279
-	 *
280
-	 * @param  int  $default
281
-	 *
282
-	 * @return int
283
-	 */
284
-	public static function getWidth(int $default = 80)
285
-	{
286
-		if (static::isWindows() || (int) shell_exec('tput cols') === 0) {
287
-			return $default;
288
-		}
289
-
290
-		return (int) shell_exec('tput cols');
291
-	}
292
-
293
-	/**
294
-	 * Attempts to determine the height of the viewable CLI window.
295
-	 *
296
-	 * @param  int  $default
297
-	 *
298
-	 * @return int
299
-	 */
300
-	public static function getHeight(int $default = 32)
301
-	{
302
-		if (static::isWindows()) {
303
-			return $default;
304
-		}
305
-
306
-		return (int) shell_exec('tput lines');
307
-	}
308
-
309
-	/**
310
-	 * Takes a string and writes it to the command line, wrapping to a maximum width. 
311
-	 * If no maximum width is specified, will wrap to the window's max.
312
-	 *
313
-	 * @param  string  $string  (null by default)
314
-	 * @param  int  $max  (0 by default)
315
-	 * @param  int $padLeft  (0 by default)
316
-	 *
317
-	 * @return string
318
-	 */
319
-	public static function wrap(string $string = null, int $max = 0, int $padLeft = 0)
320
-	{
321
-		if (empty($string)) {
322
-			return '';
323
-		}
324
-
325
-		if ($max === 0) {
326
-			$max = static::getWidth();
327
-		}
328
-
329
-		if (static::getWidth() < $max) {
330
-			$max = static::getWidth();
331
-		}
332
-
333
-		$max = $max - $padLeft;
334
-
335
-		$lines = wordwrap($string, $max);
336
-
337
-		if ($pad_left > 0) {
338
-			$lines = explode(PHP_EOL, $lines);
339
-
340
-			$first = true;
341
-
342
-			array_walk ($lines, function (&$line, $index) use ($pad_left, &$first) {
343
-
344
-				if ( ! $first) {
345
-					$line = str_repeat(' ', $pad_left) . $line;
346
-				} else {
347
-					$first = false;
348
-				}
349
-
350
-			});
351
-
352
-			$lines = implode(PHP_EOL, $lines);
353
-		}
354
-
355
-		return $lines;
356
-	}
357
-
358
- 	/**
359
- 	 * Get input from the shell, using readline or the standard STDIN.
360
- 	 *
361
- 	 * @param  string|int  $prefix  The name of the option (int if unnamed)
362
- 	 *
363
- 	 * @return string
364
- 	 */
365
- 	public static function input($prefix = '')
366
- 	{
367
- 		if (static::$readlineSupport) {
368
- 			return readline($prefix);
369
- 		}
370
-
371
- 		echo $prefix;
372
-
373
- 		return fgets(STDIN);
374
- 	}
375
-
376
- 	/**
377
- 	 * If operating system === windows.
378
- 	 * 
379
- 	 * @return string
380
- 	 */
381
- 	public static function isWindows()
382
- 	{
383
- 		return 'win' === strtolower(substr(php_uname("s"), 0, 3));
384
- 	}
385
-
386
- 	/**
387
- 	 * Enter a number of empty lines.
388
- 	 * 
389
- 	 * @param  int  $num  Number of lines to output
390
- 	 *
391
- 	 * @return void
392
- 	 */
393
- 	public static function newLine(int $num = 1)
394
- 	{
395
- 		for ($i = 0; $i < $num; $i++) {			
396
- 			static::write();
397
- 		}
398
- 	}
399
-
400
- 	/**
401
-	 * Returns the option with the given name. You can also give the option number.
402
-	 *
403
-	 * @param  string|int  $name  The name of the option (int if unnamed)
404
-	 * @param  mixed  $default  The value to return if the option is not defined
405
-	 *
406
-	 * @return mixed
407
-	 * 
408
-	 * @uses   \Syscodes\Contract\Core\Lenevor
409
-	 */
410
- 	public static function option($name, $default = null)
411
- 	{
412
- 		if ( ! isset(static::$options[$name])) {
413
- 			return Lenevor::value($default);
414
- 		}
415
-
416
- 		return static::$options[$name];
417
-	}
418
-
419
-	/**
420
-	 * Parses the command line it was called from and collects all
421
-	 * options and valid segments.
422
-	 * 
423
-	 * @return bool
424
-	 */
425
-	protected static function parseCommandLine()
426
-	{
427
-		$options = false;
428
-
429
-		for ($i = 1; $i < $_SERVER['argc']; $i++) {
430
-			if ( ! $options && mb_strpos($_SERVER['argv'][$i], '-') === false) {
431
-				static::$segments[] = $_SERVER['argv'][$i];
432
-
433
-				continue;
434
-			}
435
-
436
-			$options = true;
437
-
438
-			$args  = str_replace('-', '', $_SERVER['argv'][$i]);
439
-			$value = null;
440
-
441
-			if (isset($_SERVER['argv'][$i + 1]) && mb_strpos($_SERVER['argv'][$i + 1], '-') !== 0) {
442
-				$value = $_SERVER['argv'][$i + 1];
443
-				$i++;
444
-			}
445
-
446
-			static::$options[$args] = $value;
447
-
448
-			$options = false;
449
-		}
450
-	}
451
-
452
-	/**
453
-	 * Returns the command line string portions of the arguments, minus
454
-	 * any options, as a string.
455
-	 *
456
-	 * @return string
457
-	 */
458
-	public static function getURI()
459
-	{
460
-		return implode('/', static::$segments);
461
-	}
462
-
463
-	/**
464
-	 * Returns an individual segment.
465
-	 *
466
-	 * @param  int  $index
467
-	 * 
468
-	 * @return mixed|null
469
-	 */
470
-	public static function getSegment(int $index)
471
-	{
472
-		if ( ! isset(static::$segments[$index - 1])) {
473
-			return null;
474
-		}
475
-
476
-		return static::$segments[$index - 1];
477
-	}
478
-
479
-	/**
480
-	 * Returns the raw array of segments found.
481
-	 *
482
-	 * @return array
483
-	 */
484
-	public static function getSegments()
485
-	{
486
-		return static::$segments;
487
-	}
488
-
489
- 	/**
490
- 	 * Asks the user for input.  This can have either 1 or 2 arguments.
491
-	 *
492
-	 * Usage:
493
-	 *
494
-	 * // Waits for any key press
495
-	 * Cli::prompt();
496
-	 *
497
-	 * // Takes any input
498
-	 * $color = Cli::prompt('What is your favorite color?');
499
-	 *
500
-	 * // Takes any input, but offers default
501
-	 * $color = Cli::prompt('What is your favourite color?', 'white');
502
-	 *
503
-	 * // Will only accept the options in the array
504
-	 * $ready = Cli::prompt('Are you ready?', array('y','n'));
505
-	 *
506
-	 * @return string The user input
507
-	 */
508
- 	public static function prompt()
509
- 	{
510
- 		$args = func_get_args();
511
-
512
-		$options = [];
513
-		$output  = '';
514
-		$default = null;
515
-
516
-		// How many we got
517
-		$arg_count = count($args);
518
-
519
-		// Is the last argument a boolean? True means required
520
-		$required = end($args) === true;
521
-
522
-		// Reduce the argument count if required was passed, we don't care about that anymore
523
-		$required === true and --$arg_count;
524
-
525
-		// This method can take a few crazy combinations of arguments, so lets work it out
526
-		switch ($arg_count) {
527
-			case 2:
528
-
529
-				// E.g: $ready = Cli::prompt('Are you ready?', ['y','n']);
530
-				if (is_array($args[1])) {
531
-					list($output, $options) = $args;
532
-				}
533
-				// E.g: $color = Cli::prompt('What is your favourite color?', 'white');
534
-				elseif (is_string($args[1])) {
535
-					list($output, $default) = $args;
536
-				}
537
-
538
-			break;
539
-
540
-			case 1:
541
-
542
-				// No question (probably been asked already) so just show options
543
-				// E.g: $ready = Cli::prompt(array('y','n'));
544
-				if (is_array($args[0])) {
545
-					$options = $args[0];
546
-				}
547
-				// Question without options
548
-				// E.g: $ready = Cli::prompt('What did you do today?');
549
-				elseif (is_string($args[0])) {
550
-					$output = $args[0];
551
-				}
552
-
553
-			break;
554
-		}
555
-
556
-		// If a question has been asked with the read
557
-		if ($output !== '') {
558
-			$extra_output = '';
559
-
560
-			if ($default !== null) {
561
-				$extra_output = ' [ Default: "'.$default.'" ]';
562
-			} elseif ($options !== []) {
563
-				$extra_output = ' [ '.implode(' | ', $options).' ]';
564
-			}
565
-
566
-			fwrite(static::$stdout, $output.$extra_output.': ');
567
-		}
568
-
569
-		// Read the input from keyboard.
570
-		$input = trim(static::input()) ?: $default;
571
-
572
-		// No input provided and we require one (default will stop this being called)
573
-		if (empty($input) and $required === true) {
574
-			static::write('This is required.');
575
-			static::newLine();
576
-
577
-			$input = forward_static_call_array([__CLASS__, 'prompt'], $args);
578
-		}
579
-
580
-		// If options are provided and the choice is not in the array, tell them to try again
581
-		if ( ! empty($options) and ! in_array($input, $options)) {
582
-			static::write('This is not a valid option. Please try again.');
583
-			static::newLine();
584
-
585
-			$input = forward_static_call_array([__CLASS__, 'prompt'], $args);
586
-		}
587
-
588
-		return $input;
589
- 	}
590
-
591
- 	/**
592
- 	 * Allows you to set a commandline option from code.
593
- 	 *
594
- 	 * @param  string|int  $name  The name of the option (int if unnamed)
595
-	 * @param  mixed|null  $value  The value to set, or null to delete the option
596
-	 *
597
-	 * @return mixed
598
-	 */
599
- 	public static function setOption($name, $value = null)
600
- 	{
601
- 		if ($value == null) {
602
- 			if (isset(static::$options[$name])) {
603
- 				unset(static::$options[$name]);
604
- 			}
605
- 		} else {
606
- 			static::$options[$name] = $value;
607
- 		}
608
- 	}
609
-
610
- 	/**
611
- 	 * Waits a certain number of seconds, optionally showing a wait message and
612
-	 * waiting for a key press.
613
- 	 *
614
- 	 * @param  int  $seconds  Number of seconds
615
- 	 * @param  bool  $countdown  Show a countdown or not
616
- 	 *
617
- 	 * @return string
618
- 	 */
619
- 	public static function wait(int $seconds = 0, bool $countdown = false)
620
- 	{
621
- 		if ($countdown === true) {
622
-			$time = $seconds;
623
-
624
- 			while ($time > 0) {
625
- 				fwrite(static::$stdout, $time.'... ');
626
- 				sleep(1);
627
- 				$time--;
628
- 			}
629
-
630
- 			static::write();
631
- 		} else {
632
- 			if ($seconds = 0) {
633
- 				sleep($seconds);
634
- 			} else {
635
- 				static::write(static::$waitMsg);
636
- 				static::input();
637
- 			}
638
- 		}
639
- 	}
640
-
641
- 	/**
642
- 	 * Outputs a string to the cli.	If you send an array it will implode them 
643
- 	 * with a line break.
644
- 	 * 
645
- 	 * @param  string|array  $text  The text to output, or array of lines
646
- 	 * @param  string|null  $foreground  The foreground color
647
- 	 * @param  string|null  $background  The background color
648
- 	 *
649
- 	 * @return string
650
- 	 */
651
- 	public static function write(string $text = '', string $foreground = null, string $background = null)
652
- 	{
653
- 		if (is_array($text)) {
654
- 			$text = implode(PHP_EOL, $text);
655
- 		}
656
-
657
- 		if ($foreground OR $background) {
658
- 			$text = static::color($text, $foreground, $background);
659
- 		}
660
-
661
- 		fwrite(static::$stdout, $text.PHP_EOL);
662
- 	}
663
-
664
- 	/**
665
- 	 * Returns a well formatted table.
666
- 	 *
667
- 	 * @param  array  $tbody  List of rows
668
- 	 * @param  array  $thead  List of columns
669
- 	 *
670
- 	 * @return void
671
- 	 */
672
- 	public static function table(array $tbody, array $thead = [])
673
- 	{
674
- 		$rows = [];
675
-
676
- 		if ( ! empty($thead)) {
677
- 			$rows[] = array_values($thead);
678
- 		}
679
-
680
- 		foreach ($tbody as $tr) {
681
- 			$rows[] = count($rows);
682
- 		}
683
-
684
- 		$totalRows = count($rows);
685
-
686
- 		// Store all columns lengths
687
- 		$allColsLengths = [];
688
-
689
- 		// Store maximum lengths by column
690
- 		$maxColsLengths = [];
691
-
692
- 		for ($row = 0; $row < $totalRows; $row++) {
693
- 			$column = 0;
694
-
695
- 			foreach ($rows[$row] as $col) {
696
- 				$allColsLengths[$row][$column] = static::strlen($col);
697
-
698
- 				if ( ! isset($maxColsLengths[$column]) || $allColsLengths[$row][$column] > $maxColsLengths[$column]) {
699
- 					$maxColsLengths[$column] = $allColsLengths[$row][$column];
700
- 				}
701
-
702
- 				$column++;
703
- 			}
704
- 		}
705
-
706
- 		for ($row = 0; $row < $totalRows; $row++) {
707
- 			$column = 0;
708
-
709
- 			foreach ($rows[$row] as $col)
710
- 			{
711
- 				$diverse = $maxColsLengths[$column] - static::strlen($col);
274
+        fwrite(static::$stderr, $text.PHP_EOL);
275
+    }
276
+
277
+    /**
278
+     * Attempts to determine the width of the viewable CLI window.
279
+     *
280
+     * @param  int  $default
281
+     *
282
+     * @return int
283
+     */
284
+    public static function getWidth(int $default = 80)
285
+    {
286
+        if (static::isWindows() || (int) shell_exec('tput cols') === 0) {
287
+            return $default;
288
+        }
289
+
290
+        return (int) shell_exec('tput cols');
291
+    }
292
+
293
+    /**
294
+     * Attempts to determine the height of the viewable CLI window.
295
+     *
296
+     * @param  int  $default
297
+     *
298
+     * @return int
299
+     */
300
+    public static function getHeight(int $default = 32)
301
+    {
302
+        if (static::isWindows()) {
303
+            return $default;
304
+        }
305
+
306
+        return (int) shell_exec('tput lines');
307
+    }
308
+
309
+    /**
310
+     * Takes a string and writes it to the command line, wrapping to a maximum width. 
311
+     * If no maximum width is specified, will wrap to the window's max.
312
+     *
313
+     * @param  string  $string  (null by default)
314
+     * @param  int  $max  (0 by default)
315
+     * @param  int $padLeft  (0 by default)
316
+     *
317
+     * @return string
318
+     */
319
+    public static function wrap(string $string = null, int $max = 0, int $padLeft = 0)
320
+    {
321
+        if (empty($string)) {
322
+            return '';
323
+        }
324
+
325
+        if ($max === 0) {
326
+            $max = static::getWidth();
327
+        }
328
+
329
+        if (static::getWidth() < $max) {
330
+            $max = static::getWidth();
331
+        }
332
+
333
+        $max = $max - $padLeft;
334
+
335
+        $lines = wordwrap($string, $max);
336
+
337
+        if ($pad_left > 0) {
338
+            $lines = explode(PHP_EOL, $lines);
339
+
340
+            $first = true;
341
+
342
+            array_walk ($lines, function (&$line, $index) use ($pad_left, &$first) {
343
+
344
+                if ( ! $first) {
345
+                    $line = str_repeat(' ', $pad_left) . $line;
346
+                } else {
347
+                    $first = false;
348
+                }
349
+
350
+            });
351
+
352
+            $lines = implode(PHP_EOL, $lines);
353
+        }
354
+
355
+        return $lines;
356
+    }
357
+
358
+        /**
359
+         * Get input from the shell, using readline or the standard STDIN.
360
+         *
361
+         * @param  string|int  $prefix  The name of the option (int if unnamed)
362
+         *
363
+         * @return string
364
+         */
365
+        public static function input($prefix = '')
366
+        {
367
+            if (static::$readlineSupport) {
368
+                return readline($prefix);
369
+            }
370
+
371
+            echo $prefix;
372
+
373
+            return fgets(STDIN);
374
+        }
375
+
376
+        /**
377
+         * If operating system === windows.
378
+         * 
379
+         * @return string
380
+         */
381
+        public static function isWindows()
382
+        {
383
+            return 'win' === strtolower(substr(php_uname("s"), 0, 3));
384
+        }
385
+
386
+        /**
387
+         * Enter a number of empty lines.
388
+         * 
389
+         * @param  int  $num  Number of lines to output
390
+         *
391
+         * @return void
392
+         */
393
+        public static function newLine(int $num = 1)
394
+        {
395
+            for ($i = 0; $i < $num; $i++) {			
396
+                static::write();
397
+            }
398
+        }
399
+
400
+        /**
401
+         * Returns the option with the given name. You can also give the option number.
402
+         *
403
+         * @param  string|int  $name  The name of the option (int if unnamed)
404
+         * @param  mixed  $default  The value to return if the option is not defined
405
+         *
406
+         * @return mixed
407
+         * 
408
+         * @uses   \Syscodes\Contract\Core\Lenevor
409
+         */
410
+        public static function option($name, $default = null)
411
+        {
412
+            if ( ! isset(static::$options[$name])) {
413
+                return Lenevor::value($default);
414
+            }
415
+
416
+            return static::$options[$name];
417
+    }
418
+
419
+    /**
420
+     * Parses the command line it was called from and collects all
421
+     * options and valid segments.
422
+     * 
423
+     * @return bool
424
+     */
425
+    protected static function parseCommandLine()
426
+    {
427
+        $options = false;
428
+
429
+        for ($i = 1; $i < $_SERVER['argc']; $i++) {
430
+            if ( ! $options && mb_strpos($_SERVER['argv'][$i], '-') === false) {
431
+                static::$segments[] = $_SERVER['argv'][$i];
432
+
433
+                continue;
434
+            }
435
+
436
+            $options = true;
437
+
438
+            $args  = str_replace('-', '', $_SERVER['argv'][$i]);
439
+            $value = null;
440
+
441
+            if (isset($_SERVER['argv'][$i + 1]) && mb_strpos($_SERVER['argv'][$i + 1], '-') !== 0) {
442
+                $value = $_SERVER['argv'][$i + 1];
443
+                $i++;
444
+            }
445
+
446
+            static::$options[$args] = $value;
447
+
448
+            $options = false;
449
+        }
450
+    }
451
+
452
+    /**
453
+     * Returns the command line string portions of the arguments, minus
454
+     * any options, as a string.
455
+     *
456
+     * @return string
457
+     */
458
+    public static function getURI()
459
+    {
460
+        return implode('/', static::$segments);
461
+    }
462
+
463
+    /**
464
+     * Returns an individual segment.
465
+     *
466
+     * @param  int  $index
467
+     * 
468
+     * @return mixed|null
469
+     */
470
+    public static function getSegment(int $index)
471
+    {
472
+        if ( ! isset(static::$segments[$index - 1])) {
473
+            return null;
474
+        }
475
+
476
+        return static::$segments[$index - 1];
477
+    }
478
+
479
+    /**
480
+     * Returns the raw array of segments found.
481
+     *
482
+     * @return array
483
+     */
484
+    public static function getSegments()
485
+    {
486
+        return static::$segments;
487
+    }
488
+
489
+        /**
490
+         * Asks the user for input.  This can have either 1 or 2 arguments.
491
+         *
492
+         * Usage:
493
+         *
494
+         * // Waits for any key press
495
+         * Cli::prompt();
496
+         *
497
+         * // Takes any input
498
+         * $color = Cli::prompt('What is your favorite color?');
499
+         *
500
+         * // Takes any input, but offers default
501
+         * $color = Cli::prompt('What is your favourite color?', 'white');
502
+         *
503
+         * // Will only accept the options in the array
504
+         * $ready = Cli::prompt('Are you ready?', array('y','n'));
505
+         *
506
+         * @return string The user input
507
+         */
508
+        public static function prompt()
509
+        {
510
+            $args = func_get_args();
511
+
512
+        $options = [];
513
+        $output  = '';
514
+        $default = null;
515
+
516
+        // How many we got
517
+        $arg_count = count($args);
518
+
519
+        // Is the last argument a boolean? True means required
520
+        $required = end($args) === true;
521
+
522
+        // Reduce the argument count if required was passed, we don't care about that anymore
523
+        $required === true and --$arg_count;
524
+
525
+        // This method can take a few crazy combinations of arguments, so lets work it out
526
+        switch ($arg_count) {
527
+            case 2:
528
+
529
+                // E.g: $ready = Cli::prompt('Are you ready?', ['y','n']);
530
+                if (is_array($args[1])) {
531
+                    list($output, $options) = $args;
532
+                }
533
+                // E.g: $color = Cli::prompt('What is your favourite color?', 'white');
534
+                elseif (is_string($args[1])) {
535
+                    list($output, $default) = $args;
536
+                }
537
+
538
+            break;
539
+
540
+            case 1:
541
+
542
+                // No question (probably been asked already) so just show options
543
+                // E.g: $ready = Cli::prompt(array('y','n'));
544
+                if (is_array($args[0])) {
545
+                    $options = $args[0];
546
+                }
547
+                // Question without options
548
+                // E.g: $ready = Cli::prompt('What did you do today?');
549
+                elseif (is_string($args[0])) {
550
+                    $output = $args[0];
551
+                }
552
+
553
+            break;
554
+        }
555
+
556
+        // If a question has been asked with the read
557
+        if ($output !== '') {
558
+            $extra_output = '';
559
+
560
+            if ($default !== null) {
561
+                $extra_output = ' [ Default: "'.$default.'" ]';
562
+            } elseif ($options !== []) {
563
+                $extra_output = ' [ '.implode(' | ', $options).' ]';
564
+            }
565
+
566
+            fwrite(static::$stdout, $output.$extra_output.': ');
567
+        }
568
+
569
+        // Read the input from keyboard.
570
+        $input = trim(static::input()) ?: $default;
571
+
572
+        // No input provided and we require one (default will stop this being called)
573
+        if (empty($input) and $required === true) {
574
+            static::write('This is required.');
575
+            static::newLine();
576
+
577
+            $input = forward_static_call_array([__CLASS__, 'prompt'], $args);
578
+        }
579
+
580
+        // If options are provided and the choice is not in the array, tell them to try again
581
+        if ( ! empty($options) and ! in_array($input, $options)) {
582
+            static::write('This is not a valid option. Please try again.');
583
+            static::newLine();
584
+
585
+            $input = forward_static_call_array([__CLASS__, 'prompt'], $args);
586
+        }
587
+
588
+        return $input;
589
+        }
590
+
591
+        /**
592
+         * Allows you to set a commandline option from code.
593
+         *
594
+         * @param  string|int  $name  The name of the option (int if unnamed)
595
+         * @param  mixed|null  $value  The value to set, or null to delete the option
596
+         *
597
+         * @return mixed
598
+         */
599
+        public static function setOption($name, $value = null)
600
+        {
601
+            if ($value == null) {
602
+                if (isset(static::$options[$name])) {
603
+                    unset(static::$options[$name]);
604
+                }
605
+            } else {
606
+                static::$options[$name] = $value;
607
+            }
608
+        }
609
+
610
+        /**
611
+         * Waits a certain number of seconds, optionally showing a wait message and
612
+         * waiting for a key press.
613
+         *
614
+         * @param  int  $seconds  Number of seconds
615
+         * @param  bool  $countdown  Show a countdown or not
616
+         *
617
+         * @return string
618
+         */
619
+        public static function wait(int $seconds = 0, bool $countdown = false)
620
+        {
621
+            if ($countdown === true) {
622
+            $time = $seconds;
623
+
624
+                while ($time > 0) {
625
+                    fwrite(static::$stdout, $time.'... ');
626
+                    sleep(1);
627
+                    $time--;
628
+                }
629
+
630
+                static::write();
631
+            } else {
632
+                if ($seconds = 0) {
633
+                    sleep($seconds);
634
+                } else {
635
+                    static::write(static::$waitMsg);
636
+                    static::input();
637
+                }
638
+            }
639
+        }
640
+
641
+        /**
642
+         * Outputs a string to the cli.	If you send an array it will implode them 
643
+         * with a line break.
644
+         * 
645
+         * @param  string|array  $text  The text to output, or array of lines
646
+         * @param  string|null  $foreground  The foreground color
647
+         * @param  string|null  $background  The background color
648
+         *
649
+         * @return string
650
+         */
651
+        public static function write(string $text = '', string $foreground = null, string $background = null)
652
+        {
653
+            if (is_array($text)) {
654
+                $text = implode(PHP_EOL, $text);
655
+            }
656
+
657
+            if ($foreground OR $background) {
658
+                $text = static::color($text, $foreground, $background);
659
+            }
660
+
661
+            fwrite(static::$stdout, $text.PHP_EOL);
662
+        }
663
+
664
+        /**
665
+         * Returns a well formatted table.
666
+         *
667
+         * @param  array  $tbody  List of rows
668
+         * @param  array  $thead  List of columns
669
+         *
670
+         * @return void
671
+         */
672
+        public static function table(array $tbody, array $thead = [])
673
+        {
674
+            $rows = [];
675
+
676
+            if ( ! empty($thead)) {
677
+                $rows[] = array_values($thead);
678
+            }
679
+
680
+            foreach ($tbody as $tr) {
681
+                $rows[] = count($rows);
682
+            }
683
+
684
+            $totalRows = count($rows);
685
+
686
+            // Store all columns lengths
687
+            $allColsLengths = [];
688
+
689
+            // Store maximum lengths by column
690
+            $maxColsLengths = [];
691
+
692
+            for ($row = 0; $row < $totalRows; $row++) {
693
+                $column = 0;
694
+
695
+                foreach ($rows[$row] as $col) {
696
+                    $allColsLengths[$row][$column] = static::strlen($col);
697
+
698
+                    if ( ! isset($maxColsLengths[$column]) || $allColsLengths[$row][$column] > $maxColsLengths[$column]) {
699
+                        $maxColsLengths[$column] = $allColsLengths[$row][$column];
700
+                    }
701
+
702
+                    $column++;
703
+                }
704
+            }
705
+
706
+            for ($row = 0; $row < $totalRows; $row++) {
707
+                $column = 0;
708
+
709
+                foreach ($rows[$row] as $col)
710
+                {
711
+                    $diverse = $maxColsLengths[$column] - static::strlen($col);
712 712
  				
713
- 				if ($diverse) {
714
- 					$rows[$row][$column] = $rows[$row][$column].str_repeat(' ', $diverse);
715
- 				}
713
+                    if ($diverse) {
714
+                        $rows[$row][$column] = $rows[$row][$column].str_repeat(' ', $diverse);
715
+                    }
716 716
 
717
- 				$column++;
718
- 			} 			
719
- 		}
717
+                    $column++;
718
+                } 			
719
+            }
720 720
 
721
- 		$table = '';
721
+            $table = '';
722 722
 
723
- 		for ($row = 0; $row < $rows; $row++) {
724
- 			if (0 === $row) {
725
- 				$cols = '+';
723
+            for ($row = 0; $row < $rows; $row++) {
724
+                if (0 === $row) {
725
+                    $cols = '+';
726 726
 
727
- 				foreach ($rows[$row] as $col) {
728
- 					$cols .= str_repeat('-', static::strlen($col) + 2).'+';
729
- 				}
727
+                    foreach ($rows[$row] as $col) {
728
+                        $cols .= str_repeat('-', static::strlen($col) + 2).'+';
729
+                    }
730 730
 
731
- 				$table .= $cols.PHP_EOL;
732
- 			}
731
+                    $table .= $cols.PHP_EOL;
732
+                }
733 733
 
734
- 			$table .= '| '.implode('-', $rows[$row]).' |'.PHP_EOL;
734
+                $table .= '| '.implode('-', $rows[$row]).' |'.PHP_EOL;
735 735
 
736
- 			if (0 === $row && ! empty($thead) || $row + 1 === $rows) {
737
- 				$table .= $cols.PHP_EOL;
738
- 			}
739
- 		}
736
+                if (0 === $row && ! empty($thead) || $row + 1 === $rows) {
737
+                    $table .= $cols.PHP_EOL;
738
+                }
739
+            }
740 740
 
741
- 		fwrite(static::$stdout, $table);
742
- 	}
741
+            fwrite(static::$stdout, $table);
742
+        }
743 743
 }
744 744
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
  			throw new LenevorException(static::error("Invalid CLI foreground color: {$foreground}."));
208 208
  		}
209 209
 
210
- 		if ( $background !== null && ! Arr::exists(static::$backgroundColors, $background)) {
210
+ 		if ($background !== null && ! Arr::exists(static::$backgroundColors, $background)) {
211 211
  			throw new LenevorException(static::error("Invalid CLI background color: {$background}."));
212 212
  		}
213 213
 
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 
340 340
 			$first = true;
341 341
 
342
-			array_walk ($lines, function (&$line, $index) use ($pad_left, &$first) {
342
+			array_walk($lines, function(&$line, $index) use ($pad_left, &$first) {
343 343
 
344 344
 				if ( ! $first) {
345
-					$line = str_repeat(' ', $pad_left) . $line;
345
+					$line = str_repeat(' ', $pad_left).$line;
346 346
 				} else {
347 347
 					$first = false;
348 348
 				}
Please login to merge, or discard this patch.
src/components/Console/Application.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -34,58 +34,58 @@
 block discarded – undo
34 34
  */
35 35
 class Application implements ApplicationContracts
36 36
 {
37
-	/**
38
-	 * Get the Lenevor class instance.
39
-	 * 
40
-	 * @var \Syscodes\Contracts\Core\Lenevor $core
41
-	 */
42
-	protected $core;
37
+    /**
38
+     * Get the Lenevor class instance.
39
+     * 
40
+     * @var \Syscodes\Contracts\Core\Lenevor $core
41
+     */
42
+    protected $core;
43 43
 
44
-	/**
45
-	 * Console constructor. Initialize the console of Lenevor.
46
-	 *
47
-	 * @param  \Syscodes\Contracts\Core\Lenevor  $core
48
-	 * 
49
-	 * @return void
50
-	 */
51
-	public function __construct(Lenevor $core)
52
-	{		
53
-		// Initialize the Cli
54
-		if ($core->initCli()) {
55
-			Cli::initialize($core);
56
-		}
44
+    /**
45
+     * Console constructor. Initialize the console of Lenevor.
46
+     *
47
+     * @param  \Syscodes\Contracts\Core\Lenevor  $core
48
+     * 
49
+     * @return void
50
+     */
51
+    public function __construct(Lenevor $core)
52
+    {		
53
+        // Initialize the Cli
54
+        if ($core->initCli()) {
55
+            Cli::initialize($core);
56
+        }
57 57
 
58
-		$this->core = $core;
59
-	}
58
+        $this->core = $core;
59
+    }
60 60
 
61
-	/**
62
-	 * Runs the current command discovered on the CLI.
63
-	 *
64
-	 * @return void
65
-	 */
66
-	public function run()
67
-	{
68
-		Cli::getURI();
61
+    /**
62
+     * Runs the current command discovered on the CLI.
63
+     *
64
+     * @return void
65
+     */
66
+    public function run()
67
+    {
68
+        Cli::getURI();
69 69
 
70 70
 		
71
-	}
71
+    }
72 72
 
73
-	/**
74
-	 * Displays basic information about the Console.
75
-	 *
76
-	 * @return void
77
-	 *
78
-	 * @uses   Version::PRODUCT
79
-	 * @uses   Version::RELEASE 
80
-	 */
81
-	public function showHeader()
82
-	{		
83
-		Cli::write(Version::PRODUCT.' '
84
-			.Cli::color(Version::RELEASE, 'cyan').' | '
85
-			.'Server Time: '.Cli::color(date('Y/m/d H:i:sa'), 'light_yellow').' | '
86
-			.cli::color('['.PHP_OS.']', 'light_purple')
87
-		);
73
+    /**
74
+     * Displays basic information about the Console.
75
+     *
76
+     * @return void
77
+     *
78
+     * @uses   Version::PRODUCT
79
+     * @uses   Version::RELEASE 
80
+     */
81
+    public function showHeader()
82
+    {		
83
+        Cli::write(Version::PRODUCT.' '
84
+            .Cli::color(Version::RELEASE, 'cyan').' | '
85
+            .'Server Time: '.Cli::color(date('Y/m/d H:i:sa'), 'light_yellow').' | '
86
+            .cli::color('['.PHP_OS.']', 'light_purple')
87
+        );
88 88
 
89
-		Cli::newLine(1);
90
-	}
89
+        Cli::newLine(1);
90
+    }
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Events/Dispatcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             return $this->createClassListener($listener, $wilcard);
131 131
         }
132 132
 
133
-        return function ($event, $payload) use ($listener, $wilcard) {
133
+        return function($event, $payload) use ($listener, $wilcard) {
134 134
             if ($wilcard) {
135 135
                 return $listener($event, $payload);
136 136
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function createClassListener($listener, $wilcard = false)
151 151
     {
152
-        return function ($event, $payload) use ($listener, $wilcard) {
152
+        return function($event, $payload) use ($listener, $wilcard) {
153 153
             if ($wilcard) {
154 154
                 return call_user_func($this->createClassClosure($listener), $event, $payload);
155 155
             }
Please login to merge, or discard this patch.
src/components/Collections/Arr.php 2 patches
Indentation   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class Arr
34 34
 {
35
-	/**
36
-	 * Determine whether the value is accessible in a array.
37
-	 *
38
-	 * @param  mixed  $value The default value
39
-	 *
40
-	 * @return bool
41
-	 *
42
-	 * @uses   instanceof ArrayAccess
43
-	 */
44
-	public static function access($value) 
45
-	{
46
-		return is_array($value) || $value instanceof ArrayAccess;
47
-	}
48
-
49
-	/**
50
-	 * Add an element to an array using "dot" notation if it doesn't exist.
51
-	 *
52
-	 * @param  array  $array  The search array 
53
-	 * @param  string  $key  The key exist
54
-	 * @param  mixed  $value  The default value
55
-	 *
56
-	 * @return array 
57
-	 */
58
-	public static function add($array, $key, $value)
59
-	{
60
-		if (is_null(static::get($array, $key))) {
61
-			static::set($array, $key, $value);
62
-		}
63
-
64
-		return $array;
65
-	}
66
-
67
-	/**
35
+    /**
36
+     * Determine whether the value is accessible in a array.
37
+     *
38
+     * @param  mixed  $value The default value
39
+     *
40
+     * @return bool
41
+     *
42
+     * @uses   instanceof ArrayAccess
43
+     */
44
+    public static function access($value) 
45
+    {
46
+        return is_array($value) || $value instanceof ArrayAccess;
47
+    }
48
+
49
+    /**
50
+     * Add an element to an array using "dot" notation if it doesn't exist.
51
+     *
52
+     * @param  array  $array  The search array 
53
+     * @param  string  $key  The key exist
54
+     * @param  mixed  $value  The default value
55
+     *
56
+     * @return array 
57
+     */
58
+    public static function add($array, $key, $value)
59
+    {
60
+        if (is_null(static::get($array, $key))) {
61
+            static::set($array, $key, $value);
62
+        }
63
+
64
+        return $array;
65
+    }
66
+
67
+    /**
68 68
      * Collapse the collection items into a single array.
69 69
      * 
70 70
      * @return static
@@ -74,358 +74,358 @@  discard block
 block discarded – undo
74 74
         $results = [];
75 75
 
76 76
         foreach ($array as $values) {
77
-			if ($values instanceof Collection) {
78
-				$values = $values->all();
79
-			} elseif ( ! is_array($values)) {
80
-				continue;
81
-			}
77
+            if ($values instanceof Collection) {
78
+                $values = $values->all();
79
+            } elseif ( ! is_array($values)) {
80
+                continue;
81
+            }
82 82
 
83
-			$results[] = $values;
83
+            $results[] = $values;
84 84
         }
85 85
 
86 86
         return array_merge([], ...$results);
87 87
     }
88 88
 
89
-	/**
90
-	 * Divide an array into two arrays. One with keys and the other with values.
91
-	 *
92
-	 * @param  array  $array
93
-	 *
94
-	 * @return array
95
-	 */
96
-	public static function divide($array)
97
-	{
98
-		return [array_keys($array), array_values($array)];
99
-	}
100
-
101
-	/**
102
-	 * Get all of the given array except for a specified array of items.
103
-	 *
104
-	 * @param  array  $array
105
-	 * @param  string|array  $keys
106
-	 *
107
-	 * @return array
108
-	 */
109
-	public static function except($array, $keys)
110
-	{
111
-		static::erase($array, $keys);
112
-
113
-		return $array;
114
-	}
89
+    /**
90
+     * Divide an array into two arrays. One with keys and the other with values.
91
+     *
92
+     * @param  array  $array
93
+     *
94
+     * @return array
95
+     */
96
+    public static function divide($array)
97
+    {
98
+        return [array_keys($array), array_values($array)];
99
+    }
100
+
101
+    /**
102
+     * Get all of the given array except for a specified array of items.
103
+     *
104
+     * @param  array  $array
105
+     * @param  string|array  $keys
106
+     *
107
+     * @return array
108
+     */
109
+    public static function except($array, $keys)
110
+    {
111
+        static::erase($array, $keys);
112
+
113
+        return $array;
114
+    }
115 115
 	
116
-	/**
117
-	 * Determine if the given key exists in the provided array.
118
-	 *
119
-	 * @param  ArrayAccess|array  $array  The search array
120
-	 * @param  string|int  $key  The key exist
121
-	 *
122
-	 * @return bool
123
-	 *
124
-	 * @uses   instaceof ArrayAccess
125
-	 */
126
-	public static function exists($array, $key) 
127
-	{
128
-		if ($array instanceof ArrayAccess) {
129
-			return $array->offsetExists($key);
130
-		}
116
+    /**
117
+     * Determine if the given key exists in the provided array.
118
+     *
119
+     * @param  ArrayAccess|array  $array  The search array
120
+     * @param  string|int  $key  The key exist
121
+     *
122
+     * @return bool
123
+     *
124
+     * @uses   instaceof ArrayAccess
125
+     */
126
+    public static function exists($array, $key) 
127
+    {
128
+        if ($array instanceof ArrayAccess) {
129
+            return $array->offsetExists($key);
130
+        }
131 131
 		
132
-		return array_key_exists($key, $array);
133
-	}
134
-
135
-	/**
136
-	 * Unsets dot-notated key from an array.
137
-	 *
138
-	 * @param  array  $array  The search array
139
-	 * @param  mixed  $keys  The dot-notated key or array of keys
140
-	 *
141
-	 * @return mixed
142
-	 */
143
-	public static function erase(&$array, $keys)
144
-	{
145
-		$original = &$array;
146
-
147
-		$keys = (array) $keys;
148
-
149
-		if (count($keys) === 0) {
150
-			return;
151
-		}
152
-
153
-		foreach ($keys as $key) {
154
-			if (static::exists($array, $key)) {
155
-				unset($array[$key]);
156
-
157
-				continue;
158
-			}
132
+        return array_key_exists($key, $array);
133
+    }
134
+
135
+    /**
136
+     * Unsets dot-notated key from an array.
137
+     *
138
+     * @param  array  $array  The search array
139
+     * @param  mixed  $keys  The dot-notated key or array of keys
140
+     *
141
+     * @return mixed
142
+     */
143
+    public static function erase(&$array, $keys)
144
+    {
145
+        $original = &$array;
146
+
147
+        $keys = (array) $keys;
148
+
149
+        if (count($keys) === 0) {
150
+            return;
151
+        }
152
+
153
+        foreach ($keys as $key) {
154
+            if (static::exists($array, $key)) {
155
+                unset($array[$key]);
156
+
157
+                continue;
158
+            }
159 159
 			
160
-			$parts = explode('.', $key);
160
+            $parts = explode('.', $key);
161 161
 
162
-			// Clean up after each pass
163
-			$array = &$original;
162
+            // Clean up after each pass
163
+            $array = &$original;
164 164
 	
165
-			// traverse the array into the second last key
166
-			while (count($parts) > 1) {
167
-				$part = array_shift($parts);
165
+            // traverse the array into the second last key
166
+            while (count($parts) > 1) {
167
+                $part = array_shift($parts);
168 168
 	
169
-				if (isset($array[$part]) && is_array($array[$part])) {
170
-					$array = &$array[$key];
171
-				} else {
172
-					continue 2;
173
-				}
174
-			}
175
-
176
-			unset($array[array_shift($parts)]);
177
-		}
178
-	}
179
-
180
-	/**
181
-	 * Flatten a multi-dimensional array into a single level.
182
-	 * 
183
-	 * @param  array  $array
184
-	 * 
185
-	 * @return array
186
-	 */
187
-	public static function flatten($array)
188
-	{
189
-		$result = [];
190
-
191
-		array_walk_recursive($array, function ($value) use (&$result) {
192
-			$result[] = $value;
193
-		});
194
-
195
-		return $result;
196
-	}
169
+                if (isset($array[$part]) && is_array($array[$part])) {
170
+                    $array = &$array[$key];
171
+                } else {
172
+                    continue 2;
173
+                }
174
+            }
175
+
176
+            unset($array[array_shift($parts)]);
177
+        }
178
+    }
179
+
180
+    /**
181
+     * Flatten a multi-dimensional array into a single level.
182
+     * 
183
+     * @param  array  $array
184
+     * 
185
+     * @return array
186
+     */
187
+    public static function flatten($array)
188
+    {
189
+        $result = [];
190
+
191
+        array_walk_recursive($array, function ($value) use (&$result) {
192
+            $result[] = $value;
193
+        });
194
+
195
+        return $result;
196
+    }
197 197
 	
198
-	/**
199
-	 * Fetch a flattened array of a nested array element.
200
-	 * 
201
-	 * @param  array  $array
202
-	 * @param  string  $key
203
-	 * 
204
-	 * @return array
205
-	 */
206
-	public static function fetch($array, $key)
207
-	{
208
-		foreach (explode('.', $key) as $segment) {
209
-			$results = array();
198
+    /**
199
+     * Fetch a flattened array of a nested array element.
200
+     * 
201
+     * @param  array  $array
202
+     * @param  string  $key
203
+     * 
204
+     * @return array
205
+     */
206
+    public static function fetch($array, $key)
207
+    {
208
+        foreach (explode('.', $key) as $segment) {
209
+            $results = array();
210 210
 			
211
-			foreach ($array as $value) {
212
-				if (array_key_exists($segment, $value = (array) $value)) {
213
-					$results[] = $value[$segment];
214
-				}
215
-			}
211
+            foreach ($array as $value) {
212
+                if (array_key_exists($segment, $value = (array) $value)) {
213
+                    $results[] = $value[$segment];
214
+                }
215
+            }
216 216
 			
217
-			$array = array_values($results);
218
-		}
217
+            $array = array_values($results);
218
+        }
219 219
 		
220
-		return array_values($results);
221
-	}
222
-
223
-	/**
224
-	 * Return the first element in an array passing a given truth test.
225
-	 *
226
-	 * @param  array  $array 
227
-	 * @param  \Closure  $callback
228
-	 * @param  mixed  $default  (null by default)
229
-	 *
230
-	 * @return mixed
231
-	 */
232
-	public static function first($array, callable $callback, $default = null)
233
-	{
234
-		foreach ($array as $key => $value) { 
235
-			if (call_user_func($callback, $key, $value)) return $value;
236
-		}
237
-
238
-		return value($default);
239
-	}	
240
-
241
-	/**
242
-	 * Get an item from an array using "dot" notation.
243
-	 *
244
-	 * @param  \ArrayAccess|array  $array  The search array
245
-	 * @param  string  $key  The dot-notated key or array of keys
246
-	 * @param  mixed  $default  The default value
247
-	 *
248
-	 * @return mixed
249
-	 */
250
-	public static function get($array, $key, $default = null)
251
-	{
252
-		if ( ! static::access($array)) {
253
-			return value($default);
254
-		}
255
-
256
-		if (static::exists($array, $key)) {
257
-			return $array[$key];
258
-		}
259
-
260
-		foreach (explode('.', $key) as $segm) {
261
-			if (static::access($array) && static::exists($array, $segm)) {
262
-				$array = $array[$segm];
263
-			} else {
264
-				return value($default);
265
-			}
266
-		}
267
-
268
-		return $array;		
269
-	}
270
-
271
-	/**
272
-	 * Return the last element in an array passing a given truth test.
273
-	 *
274
-	 * @param  array  $array 
275
-	 * @param  \Closure  $callback
276
-	 * @param  mixed  $default 
277
-	 *
278
-	 * @return mixed
279
-	 *
280
-	 * @uses   \Syscodes\Support\Arr::first
281
-	 */
282
-	public static function last($array, $callback, $default = null)
283
-	{
284
-		return static::first(array_reverse($array), $callback, $default);
285
-	}
286
-
287
-	/**
288
-	 * Check if an item exists in an array using "dot" notation.
289
-	 * 
290
-	 * @param  array  $array
291
-	 * @param  string  $key
292
-	 * 
293
-	 * @return bool
294
-	 */
295
-	public static function has($array, $key)
296
-	{
297
-		if (empty($array) || is_null($key)) return false;
220
+        return array_values($results);
221
+    }
222
+
223
+    /**
224
+     * Return the first element in an array passing a given truth test.
225
+     *
226
+     * @param  array  $array 
227
+     * @param  \Closure  $callback
228
+     * @param  mixed  $default  (null by default)
229
+     *
230
+     * @return mixed
231
+     */
232
+    public static function first($array, callable $callback, $default = null)
233
+    {
234
+        foreach ($array as $key => $value) { 
235
+            if (call_user_func($callback, $key, $value)) return $value;
236
+        }
237
+
238
+        return value($default);
239
+    }	
240
+
241
+    /**
242
+     * Get an item from an array using "dot" notation.
243
+     *
244
+     * @param  \ArrayAccess|array  $array  The search array
245
+     * @param  string  $key  The dot-notated key or array of keys
246
+     * @param  mixed  $default  The default value
247
+     *
248
+     * @return mixed
249
+     */
250
+    public static function get($array, $key, $default = null)
251
+    {
252
+        if ( ! static::access($array)) {
253
+            return value($default);
254
+        }
255
+
256
+        if (static::exists($array, $key)) {
257
+            return $array[$key];
258
+        }
259
+
260
+        foreach (explode('.', $key) as $segm) {
261
+            if (static::access($array) && static::exists($array, $segm)) {
262
+                $array = $array[$segm];
263
+            } else {
264
+                return value($default);
265
+            }
266
+        }
267
+
268
+        return $array;		
269
+    }
270
+
271
+    /**
272
+     * Return the last element in an array passing a given truth test.
273
+     *
274
+     * @param  array  $array 
275
+     * @param  \Closure  $callback
276
+     * @param  mixed  $default 
277
+     *
278
+     * @return mixed
279
+     *
280
+     * @uses   \Syscodes\Support\Arr::first
281
+     */
282
+    public static function last($array, $callback, $default = null)
283
+    {
284
+        return static::first(array_reverse($array), $callback, $default);
285
+    }
286
+
287
+    /**
288
+     * Check if an item exists in an array using "dot" notation.
289
+     * 
290
+     * @param  array  $array
291
+     * @param  string  $key
292
+     * 
293
+     * @return bool
294
+     */
295
+    public static function has($array, $key)
296
+    {
297
+        if (empty($array) || is_null($key)) return false;
298 298
 		
299
-		if (array_key_exists($key, $array)) return true;
299
+        if (array_key_exists($key, $array)) return true;
300 300
 		
301
-		foreach (explode('.', $key) as $segment) {
302
-			if ( ! is_array($array) || ! static::exists($array, $segment)) {
303
-				return false;
304
-			}
301
+        foreach (explode('.', $key) as $segment) {
302
+            if ( ! is_array($array) || ! static::exists($array, $segment)) {
303
+                return false;
304
+            }
305 305
 			
306
-			$array = $array[$segment];
307
-		}
306
+            $array = $array[$segment];
307
+        }
308 308
 		
309
-		return true;
310
-	}
311
-
312
-	/**
313
-	 * Get a subset of the items from the given array.
314
-	 * 
315
-	 * @param  array  $array
316
-	 * @param  array|string  $keys
317
-	 * 
318
-	 * @return array
319
-	 */
320
-	public static function only($array, $keys)
321
-	{
322
-		return array_intersect_key($array, array_flip($array), $keys);
323
-	}
324
-
325
-	/**
326
-	 * Sets a value in an array using "dot" notation.
327
-	 *
328
-	 * @param  array  $array  The search array
329
-	 * @param  string  $key  The dot-notated key or array of keys
330
-	 * @param  mixed  $value  The default value
331
-	 *
332
-	 * @return mixed
333
-	 */
334
-	public static function set(& $array, $key, $value = null)
335
-	{
336
-		$keys = explode('.', $key);
337
-
338
-		while (count($keys) > 1) {
339
-			$key = array_shift($keys);
340
-
341
-			if ( ! static::exists($array, $key)) {
342
-				$array[$key] = [];
343
-			}
344
-
345
-			$array =& $array[$key];
346
-		}
347
-
348
-		$array[array_shift($keys)] = $value;
349
-
350
-		return $array;
351
-	}
352
-
353
-	/**
354
-	 * Push an item onto the beginning of an array.
355
-	 * 
356
-	 * @param  mixed  $array
357
-	 * @param  mixed  $value
358
-	 * @param  mixed  key  (null by default)
359
-	 * 
360
-	 * @return array
361
-	 */
362
-	public static function prepend($array, $value, $key = null)
363
-	{
364
-		if (func_num_args() == 2) {
365
-			array_unshift($array, $value);
366
-		} else {
367
-			$array = [$key => $value] + $array;
368
-		}
369
-
370
-		return $array;
371
-	}
372
-
373
-	/**
374
-	 * Get a value from the array, and remove it.
375
-	 * 
376
-	 * @param  array  $array
377
-	 * @param  string  $key
378
-	 * @param  mixed  $default  (null by default)
379
-	 * 
380
-	 * @return mixed
381
-	 */
382
-	public static function pull(&$array, $key, $default = null)
383
-	{
384
-		$value = static::get($array, $key, $default);
385
-
386
-		static::erase($array, $key);
387
-
388
-		return $value;
389
-	}
390
-
391
-	/**
392
-	 * Convert the array into a query string.
393
-	 * 
394
-	 * @param  array  $array
395
-	 * 
396
-	 * @return array
397
-	 */
398
-	public static function query($array)
399
-	{
400
-		return http_build_query($array, null, '&', PHP_QUERY_RFC3986);
401
-	}
402
-
403
-	/**
404
-	 * Filter the array using the given callback.
405
-	 * 
406
-	 * @param  array  $array
407
-	 * @param  \Callable  $callback
408
-	 * 
409
-	 * @return array
410
-	 */
411
-	public static function where($array, Callable $callback)
412
-	{
413
-		return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
414
-	}
415
-
416
-	/**
417
-	 * If the given value is not an array and not null, wrap it in one.
418
-	 * 
419
-	 * @param  mixed  $value
420
-	 * 
421
-	 * @return array
422
-	 */
423
-	public static function wrap($value)
424
-	{
425
-		if (is_null($value)) {
426
-			return [];
427
-		}
428
-
429
-		return is_array($value) ? $value : [$value];
430
-	}
309
+        return true;
310
+    }
311
+
312
+    /**
313
+     * Get a subset of the items from the given array.
314
+     * 
315
+     * @param  array  $array
316
+     * @param  array|string  $keys
317
+     * 
318
+     * @return array
319
+     */
320
+    public static function only($array, $keys)
321
+    {
322
+        return array_intersect_key($array, array_flip($array), $keys);
323
+    }
324
+
325
+    /**
326
+     * Sets a value in an array using "dot" notation.
327
+     *
328
+     * @param  array  $array  The search array
329
+     * @param  string  $key  The dot-notated key or array of keys
330
+     * @param  mixed  $value  The default value
331
+     *
332
+     * @return mixed
333
+     */
334
+    public static function set(& $array, $key, $value = null)
335
+    {
336
+        $keys = explode('.', $key);
337
+
338
+        while (count($keys) > 1) {
339
+            $key = array_shift($keys);
340
+
341
+            if ( ! static::exists($array, $key)) {
342
+                $array[$key] = [];
343
+            }
344
+
345
+            $array =& $array[$key];
346
+        }
347
+
348
+        $array[array_shift($keys)] = $value;
349
+
350
+        return $array;
351
+    }
352
+
353
+    /**
354
+     * Push an item onto the beginning of an array.
355
+     * 
356
+     * @param  mixed  $array
357
+     * @param  mixed  $value
358
+     * @param  mixed  key  (null by default)
359
+     * 
360
+     * @return array
361
+     */
362
+    public static function prepend($array, $value, $key = null)
363
+    {
364
+        if (func_num_args() == 2) {
365
+            array_unshift($array, $value);
366
+        } else {
367
+            $array = [$key => $value] + $array;
368
+        }
369
+
370
+        return $array;
371
+    }
372
+
373
+    /**
374
+     * Get a value from the array, and remove it.
375
+     * 
376
+     * @param  array  $array
377
+     * @param  string  $key
378
+     * @param  mixed  $default  (null by default)
379
+     * 
380
+     * @return mixed
381
+     */
382
+    public static function pull(&$array, $key, $default = null)
383
+    {
384
+        $value = static::get($array, $key, $default);
385
+
386
+        static::erase($array, $key);
387
+
388
+        return $value;
389
+    }
390
+
391
+    /**
392
+     * Convert the array into a query string.
393
+     * 
394
+     * @param  array  $array
395
+     * 
396
+     * @return array
397
+     */
398
+    public static function query($array)
399
+    {
400
+        return http_build_query($array, null, '&', PHP_QUERY_RFC3986);
401
+    }
402
+
403
+    /**
404
+     * Filter the array using the given callback.
405
+     * 
406
+     * @param  array  $array
407
+     * @param  \Callable  $callback
408
+     * 
409
+     * @return array
410
+     */
411
+    public static function where($array, Callable $callback)
412
+    {
413
+        return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
414
+    }
415
+
416
+    /**
417
+     * If the given value is not an array and not null, wrap it in one.
418
+     * 
419
+     * @param  mixed  $value
420
+     * 
421
+     * @return array
422
+     */
423
+    public static function wrap($value)
424
+    {
425
+        if (is_null($value)) {
426
+            return [];
427
+        }
428
+
429
+        return is_array($value) ? $value : [$value];
430
+    }
431 431
 }
432 432
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -232,7 +232,9 @@  discard block
 block discarded – undo
232 232
 	public static function first($array, callable $callback, $default = null)
233 233
 	{
234 234
 		foreach ($array as $key => $value) { 
235
-			if (call_user_func($callback, $key, $value)) return $value;
235
+			if (call_user_func($callback, $key, $value)) {
236
+			    return $value;
237
+			}
236 238
 		}
237 239
 
238 240
 		return value($default);
@@ -294,9 +296,13 @@  discard block
 block discarded – undo
294 296
 	 */
295 297
 	public static function has($array, $key)
296 298
 	{
297
-		if (empty($array) || is_null($key)) return false;
299
+		if (empty($array) || is_null($key)) {
300
+		    return false;
301
+		}
298 302
 		
299
-		if (array_key_exists($key, $array)) return true;
303
+		if (array_key_exists($key, $array)) {
304
+		    return true;
305
+		}
300 306
 		
301 307
 		foreach (explode('.', $key) as $segment) {
302 308
 			if ( ! is_array($array) || ! static::exists($array, $segment)) {
Please login to merge, or discard this patch.
src/components/Collections/Collection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             return array_search($value, $this->items, $strict);
517 517
         }
518 518
 
519
-        foreach($this->items as $key => $item) {
519
+        foreach ($this->items as $key => $item) {
520 520
             if ($value($item, $key)) {
521 521
                 return $key;
522 522
             }
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
     {
677 677
         if (is_array($items)) {
678 678
             return $items;
679
-        } elseif($items instanceof Arrayable) {
679
+        } elseif ($items instanceof Arrayable) {
680 680
             return $items->toArray();
681 681
         } elseif ($items instanceof Jsonable) {
682 682
             return json_decode($items->toJson(), true);
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.