Skip to content

Commit c41180c

Browse files
committed
a1.0.1
Update to comply with the PSR-12 standard
1 parent beb29b5 commit c41180c

7 files changed

+197
-63
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/.idea/
33
/.git/
44
/composer.lock
5+
/*.log
6+
/null

src/BugCatcher.php

+36-13
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,58 @@
11
<?php
22

3+
/**
4+
* PHP Development Tools.
5+
* PHP Version required 7.4.* or higher
6+
*
7+
* @see https://github.com/arcanisgk/PHP-Development-Tools
8+
*
9+
* @author Walter Nuñez (arcanisgk/original founder)
10+
11+
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
12+
* @license For the full copyright and licence information, please view the LICENSE
13+
* @note This program is distributed in the hope that it will be useful
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE.
16+
*/
17+
318
declare(strict_types=1);
419

520
namespace ArcanisGK\PhpDevelopmentTool;
621

22+
/**
23+
* BugCatcher Class.
24+
*/
725
class BugCatcher
826
{
9-
1027
/**
1128
* @var BugCatcher|null
1229
*/
1330

1431
private static ?BugCatcher $instance = null;
32+
1533
/**
1634
* @var string
1735
*/
1836

1937
private string $line_separator;
38+
2039
/**
2140
* @var bool
2241
*/
2342

2443
private bool $display_error;
44+
2545
/**
2646
* @var bool
2747
*/
2848

2949
private bool $to_log;
3050

31-
private string $dir_log;
51+
/**
52+
* @var string
53+
*/
3254

55+
private string $dir_log;
3356

3457
/**
3558
* this class is armed automatically at the moment it is instantiated and remains active.
@@ -38,17 +61,11 @@ class BugCatcher
3861
public function __construct(array $data)
3962
{
4063
$this->setLineSeparator($this->detectLineSeparator());
41-
4264
$this->setDisplayError($this->isDisplayErrors());
43-
4465
$this->setToLog($this->isDisplayErrors());
45-
4666
$this->setDirLog($data['dir_log']);
47-
4867
register_shutdown_function([$this, "shutdownHandler"]);
49-
5068
set_exception_handler([$this, "exceptionHandler"]);
51-
5269
set_error_handler([$this, "errorHandler"]);
5370
}
5471

@@ -114,6 +131,7 @@ private function setToLog(bool $to_log): void
114131
/**
115132
* @return string
116133
*/
134+
117135
public function getDirLog(): string
118136
{
119137
return $this->dir_log;
@@ -122,12 +140,12 @@ public function getDirLog(): string
122140
/**
123141
* @param string $dir_log
124142
*/
143+
125144
public function setDirLog(string $dir_log): void
126145
{
127146
$this->dir_log = $dir_log;
128147
}
129148

130-
131149
/**
132150
* @return void
133151
*/
@@ -233,7 +251,8 @@ private function toLog(array $error_array)
233251
{
234252
$trace = preg_replace("/\r|\n|\r\n/", "", $error_array['trace_msg']);
235253

236-
$error_smg_log = time() . ' ' . date(
254+
$error_smg_log = time() . ' ' .
255+
date(
237256
'Y-m-d H:i:s'
238257
) . ' ' . $error_array['description'] .
239258
' Trace: ' . $trace . PHP_EOL;
@@ -280,8 +299,12 @@ public function exceptionHandler($e): void
280299
* @return void
281300
*/
282301

283-
public function errorHandler($error_level = null, $error_desc = null, $error_file = null, $error_line = null): void
284-
{
302+
public function errorHandler(
303+
$error_level = null,
304+
$error_desc = null,
305+
$error_file = null,
306+
$error_line = null
307+
): void {
285308
$this->cleanOutput();
286309
$trace = array_reverse(debug_backtrace());
287310
array_pop($trace);
@@ -315,4 +338,4 @@ private function getToLog(): bool
315338
{
316339
return $this->to_log;
317340
}
318-
}
341+
}

src/CliOutput.php

+44-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
<?php
22

3+
/**
4+
* PHP Development Tools.
5+
* PHP Version required 7.4.* or higher
6+
*
7+
* @see https://github.com/arcanisgk/PHP-Development-Tools
8+
*
9+
* @author Walter Nuñez (arcanisgk/original founder)
10+
11+
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
12+
* @license For the full copyright and licence information, please view the LICENSE
13+
* @note This program is distributed in the hope that it will be useful
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE.
16+
*/
17+
18+
declare(strict_types=1);
19+
320
namespace ArcanisGK\PhpDevelopmentTool;
421

22+
/**
23+
* CliOutput Class.
24+
*/
525
class CliOutput
626
{
7-
827
/**
928
* @var CliOutput|null
1029
*/
1130

1231
private static ?CliOutput $instance = null;
32+
1333
/**
1434
* @var array
1535
*/
1636

1737
private array $cli_square;
38+
1839
/**
1940
* @var string
2041
*/
@@ -121,7 +142,8 @@ private function toBoxCli(
121142
$calc_footer = $n_lines - $n_footer;
122143
$f_top = $draw->tl . str_repeat($draw->h, $max_len + 2) . $draw->tr;
123144
$f_button = $draw->bl . str_repeat($draw->h, $max_len + 2) . $draw->br;
124-
$result .= ($highlight && 0 != $n_header) ? $cli_c_hf . $f_top . $cli_EOL . PHP_EOL : $cli_c_r . $f_top . $cli_EOL . PHP_EOL;
145+
$result .= ($highlight && 0 != $n_header) ? $cli_c_hf . $f_top . $cli_EOL . PHP_EOL :
146+
$cli_c_r . $f_top . $cli_EOL . PHP_EOL;
125147
foreach ($source as $line) {
126148
$addEmpty = '';
127149
$line_txt = '';
@@ -137,13 +159,19 @@ private function toBoxCli(
137159
$line_txt .= $cli_c_r . $draw->v . ' ' . $line . $addEmpty . ' ' . $draw->v . $cli_EOL;
138160
}
139161
if (0 != $n_header && $i == $n_header - 1) {
140-
$line_txt .= PHP_EOL . $cli_c_hf . $draw->ls . str_repeat(
162+
$line_txt .= PHP_EOL . $cli_c_hf . $draw->ls .
163+
str_repeat(
141164
$draw->hs,
142165
$max_len + 2
143166
) . $draw->rs . $cli_EOL . PHP_EOL;
144167
} elseif (0 != $n_footer && $calc_footer - 1 == $i) {
145-
$line_txt .= PHP_EOL . $cli_c_r . $draw->v . str_repeat(' ', $max_len + 2) . $draw->v . $cli_EOL;
146-
$line_txt .= PHP_EOL . $cli_c_hf . $draw->ls . str_repeat(
168+
$line_txt .= PHP_EOL . $cli_c_r . $draw->v .
169+
str_repeat(
170+
' ',
171+
$max_len + 2
172+
) . $draw->v . $cli_EOL;
173+
$line_txt .= PHP_EOL . $cli_c_hf . $draw->ls .
174+
str_repeat(
147175
$draw->hs,
148176
$max_len + 2
149177
) . $draw->rs . $cli_EOL . PHP_EOL;
@@ -153,7 +181,8 @@ private function toBoxCli(
153181
$result .= $line_txt;
154182
++$i;
155183
}
156-
$result .= ($highlight && 0 != $n_header) ? $cli_c_hf . $f_button . $cli_EOL : $cli_c_r . $f_button . $cli_EOL . PHP_EOL;
184+
$result .= ($highlight && 0 != $n_header) ? $cli_c_hf . $f_button . $cli_EOL :
185+
$cli_c_r . $f_button . $cli_EOL . PHP_EOL;
157186
}
158187

159188
return $result;
@@ -162,6 +191,7 @@ private function toBoxCli(
162191
/**
163192
* @return int
164193
*/
194+
165195
private function getWindowLimit(): int
166196
{
167197
$WidthReal = shell_exec('MODE 2> null') ?? shell_exec('tput cols');
@@ -196,11 +226,16 @@ private function checkIsFit($max_len, $limit_len): bool
196226
/**
197227
* @return array
198228
*/
229+
199230
public function getCliSquare(): array
200231
{
201232
return $this->cli_square;
202233
}
203234

235+
/**
236+
* @return void
237+
*/
238+
204239
public function setCliSquare(): void
205240
{
206241
$cli_square = [];
@@ -239,6 +274,7 @@ private function getStringFromErrorArray(array $error_array): string
239274
/**
240275
* @return string
241276
*/
277+
242278
public function getRetrieveData(): string
243279
{
244280
return $this->retrieve_data;
@@ -247,10 +283,9 @@ public function getRetrieveData(): string
247283
/**
248284
* @param string $retrieve_data
249285
*/
286+
250287
public function setRetrieveData(string $retrieve_data): void
251288
{
252289
$this->retrieve_data = $retrieve_data;
253290
}
254-
255-
256-
}
291+
}

src/FileAndDirectoryManager.php

-9
This file was deleted.

src/RequestType.php

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/**
4+
* PHP Development Tools.
5+
* PHP Version required 7.4.* or higher
6+
*
7+
* @see https://github.com/arcanisgk/PHP-Development-Tools
8+
*
9+
* @author Walter Nuñez (arcanisgk/original founder)
10+
11+
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
12+
* @license For the full copyright and licence information, please view the LICENSE
13+
* @note This program is distributed in the hope that it will be useful
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE.
16+
*/
417

18+
declare(strict_types=1);
519

620
namespace ArcanisGK\PhpDevelopmentTool;
721

22+
/**
23+
* RequestType Class.
24+
*/
825
class RequestType
926
{
10-
1127
/**
1228
* @var RequestType|null
1329
*/
@@ -57,4 +73,4 @@ private function isJson(array $var): bool
5773

5874
return json_last_error() === JSON_ERROR_NONE;
5975
}
60-
}
76+
}

src/WebCLIDetector.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/**
4+
* PHP Development Tools.
5+
* PHP Version required 7.4.* or higher
6+
*
7+
* @see https://github.com/arcanisgk/PHP-Development-Tools
8+
*
9+
* @author Walter Nuñez (arcanisgk/original founder)
10+
11+
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
12+
* @license For the full copyright and licence information, please view the LICENCE
13+
* @note This program is distributed in the hope that it will be useful
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE.
16+
*/
417

18+
declare(strict_types=1);
519

620
namespace ArcanisGK\PhpDevelopmentTool;
721

@@ -10,7 +24,6 @@
1024
*/
1125
class WebCLIDetector
1226
{
13-
1427
/**
1528
* @const string
1629
*/

0 commit comments

Comments
 (0)