Passed
Push — 0.7.0 ( d23ad8...f7e7ba )
by Alexander
02:48 queued 11s
created
src/components/Dotenv/Repository/Adapters/EnvAdapter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,14 +70,14 @@
 block discarded – undo
70 70
         return null;
71 71
     }
72 72
 
73
-     /**
74
-     * Write to an environment variable.
75
-     * 
76
-     * @param  string  $name
77
-     * @param  string  $value
78
-     * 
79
-     * @return bool
80
-     */
73
+        /**
74
+         * Write to an environment variable.
75
+         * 
76
+         * @param  string  $name
77
+         * @param  string  $value
78
+         * 
79
+         * @return bool
80
+         */
81 81
     public function write(string $name, string $value)
82 82
     {
83 83
         if (empty($_ENV[$name]))
Please login to merge, or discard this patch.
src/components/Dotenv/Repository/Adapters/ServerAdapter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -69,14 +69,14 @@
 block discarded – undo
69 69
         return null;
70 70
     }
71 71
 
72
-     /**
73
-     * Write to an environment variable.
74
-     * 
75
-     * @param  string  $name
76
-     * @param  string  $value
77
-     * 
78
-     * @return bool
79
-     */
72
+        /**
73
+         * Write to an environment variable.
74
+         * 
75
+         * @param  string  $name
76
+         * @param  string  $value
77
+         * 
78
+         * @return bool
79
+         */
80 80
     public function write(string $name, string $value)
81 81
     {
82 82
         $notHttpName = 0 !== strpos($name, 'HTTP_');
Please login to merge, or discard this patch.
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/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.