Skip to content

Commit 792bd00

Browse files
committed
Comments updates.
1 parent 1878136 commit 792bd00

File tree

9 files changed

+80
-60
lines changed

9 files changed

+80
-60
lines changed

bin/console

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ try {
5555
$app = (new App\Libs\Initializer())->boot();
5656
} catch (Throwable $e) {
5757
$message = sprintf(
58-
'Unhandled Exception [%s] was thrown. With message [%s] in [%s:%d].',
58+
'Unhandled Exception [%s] was thrown in CLI boot context. With message [%s] in [%s:%d].',
5959
$e::class,
6060
$e->getMessage(),
6161
array_reverse(explode(ROOT_PATH, $e->getFile(), 2))[0],

container/files/init-container.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if [ 0 = "${WS_DISABLE_HTTP}" ]; then
5555
caddy start --config /opt/config/Caddyfile
5656
fi
5757

58-
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Caching tool Routes."
58+
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Caching tool routes."
5959
/opt/bin/console system:routes
6060

6161
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Running database migrations."
@@ -64,7 +64,7 @@ echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Running database migrations."
6464
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Running database maintenance tasks."
6565
/opt/bin/console system:db:maintenance
6666

67-
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Ensuring State table has correct indexes."
67+
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Ensuring state table has correct indexes."
6868
/opt/bin/console system:index
6969

7070
if [ 0 = "${WS_DISABLE_CRON}" ]; then
@@ -73,7 +73,7 @@ if [ 0 = "${WS_DISABLE_CRON}" ]; then
7373
rm -f "/tmp/job-runner.pid"
7474
fi
7575

76-
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting Tasks Scheduler."
76+
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting tasks scheduler."
7777
/opt/bin/job-runner &
7878
fi
7979

public/index.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@
4747
} catch (Throwable $e) {
4848
fwrite(
4949
STDERR,
50-
trim(sprintf("PANIC: %s: %s (%s:%d).", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()))
50+
trim(
51+
sprintf(
52+
'Unhandled Exception [%s] was thrown at HTTP boot context. With message [%s] in [%s:%d].',
53+
$e::class,
54+
$e->getMessage(),
55+
array_reverse(explode(ROOT_PATH, $e->getFile(), 2))[0],
56+
$e->getLine()
57+
)
58+
)
5159
);
5260

5361
if (!headers_sent()) {

src/Command.php

+42-30
Original file line numberDiff line numberDiff line change
@@ -171,42 +171,54 @@ protected function getBackend(string $name, array $config = []): iClient
171171

172172
protected function displayContent(array $content, OutputInterface $output, string $mode = 'json'): void
173173
{
174-
if ('json' === $mode) {
175-
$output->writeln(
176-
json_encode(
177-
value: $content,
178-
flags: JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE
179-
)
180-
);
181-
} elseif ('table' === $mode) {
182-
$list = [];
174+
switch ($mode) {
175+
case 'json':
176+
$output->writeln(
177+
json_encode(
178+
value: $content,
179+
flags: JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE
180+
)
181+
);
182+
break;
183+
case 'table':
184+
$list = [];
183185

184-
foreach ($content as $_ => $item) {
185-
if (false === is_array($item)) {
186-
$item = [$_ => $item];
187-
}
186+
foreach ($content as $_ => $item) {
187+
if (false === is_array($item)) {
188+
$item = [$_ => $item];
189+
}
188190

189-
$subItem = [];
191+
$subItem = [];
190192

191-
foreach ($item as $key => $leaf) {
192-
if (true === is_array($leaf)) {
193-
continue;
193+
foreach ($item as $key => $leaf) {
194+
if (true === is_array($leaf)) {
195+
continue;
196+
}
197+
$subItem[$key] = $leaf;
194198
}
195-
$subItem[$key] = $leaf;
196-
}
197199

198-
$list[] = $subItem;
199-
$list[] = new TableSeparator();
200-
}
200+
$list[] = $subItem;
201+
$list[] = new TableSeparator();
202+
}
201203

202-
if (!empty($list)) {
203-
array_pop($list);
204-
(new Table($output))->setStyle('box')->setHeaders(
205-
array_map(fn($title) => is_string($title) ? ucfirst($title) : $title, array_keys($list[0]))
206-
)->setRows($list)->render();
207-
}
208-
} else {
209-
$output->writeln(Yaml::dump($content, 8, 2));
204+
if (!empty($list)) {
205+
array_pop($list);
206+
(new Table($output))
207+
->setStyle(name: 'box')
208+
->setHeaders(
209+
array_map(
210+
callback: fn($title) => is_string($title) ? ucfirst($title) : $title,
211+
array: array_keys($list[0])
212+
)
213+
)
214+
->setRows(rows: $list)
215+
->render();
216+
}
217+
break;
218+
case 'yaml':
219+
default:
220+
$output->writeln(Yaml::dump(input: $content, inline: 8, indent: 2));
221+
break;
210222
}
211223
}
212224

src/Libs/Guid.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ final class Guid implements JsonSerializable, Stringable
6161
private static LoggerInterface|null $logger = null;
6262

6363
/**
64-
* Create List of db => external id list.
64+
* Create list of db => external id list.
6565
*
66-
* @param array $guids A Key/value pair of db => external id. For example, [ "guid_imdb" => "tt123456789" ]
66+
* @param array $guids A key/value a pair of db => external id. For example, [ "guid_imdb" => "tt123456789" ]
6767
* @param array $context
6868
*/
6969
public function __construct(array $guids, array $context = [])
@@ -135,7 +135,7 @@ public function __construct(array $guids, array $context = [])
135135
}
136136

137137
/**
138-
* Set Logger.
138+
* Set logger.
139139
*
140140
* @param LoggerInterface $logger
141141
* @return void
@@ -146,7 +146,7 @@ public static function setLogger(LoggerInterface $logger): void
146146
}
147147

148148
/**
149-
* Get Supported External ids sources.
149+
* Get supported external ids sources.
150150
*
151151
* @return array<string,string>
152152
*/
@@ -171,7 +171,7 @@ public static function fromArray(array $payload, array $context = []): self
171171
/**
172172
* Validate id value against expected format.
173173
*
174-
* @param string $db guid source
174+
* @param string $db guid source.
175175
* @param string|int $id guid source id.
176176
*
177177
* @return bool
@@ -238,7 +238,7 @@ public function getAll(): array
238238
}
239239

240240
/**
241-
* Get Instance of logger.
241+
* Get instance of logger.
242242
*
243243
* @return LoggerInterface
244244
*/

src/Libs/Mappers/ImportInterface.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
interface ImportInterface extends Countable
1414
{
1515
/**
16-
* Initiate Mapper.
16+
* Initiate mapper.
1717
*
1818
* @param array $options
1919
*
@@ -31,7 +31,7 @@ public function setOptions(array $options = []): self;
3131
public function loadData(DateTimeInterface|null $date = null): self;
3232

3333
/**
34-
* Add Entity. it has to search for
34+
* Add entity. it has to search for
3535
* existing entity, and if found update it.
3636
*
3737
* @param StateInterface $entity Refers to the item state from backend.
@@ -42,7 +42,7 @@ public function loadData(DateTimeInterface|null $date = null): self;
4242
public function add(StateInterface $entity, array $opts = []): self;
4343

4444
/**
45-
* Get Entity.
45+
* Get entity.
4646
*
4747
* @param StateInterface $entity
4848
*
@@ -51,7 +51,7 @@ public function add(StateInterface $entity, array $opts = []): self;
5151
public function get(StateInterface $entity): null|StateInterface;
5252

5353
/**
54-
* Remove Entity.
54+
* Remove entity.
5555
*
5656
* @param StateInterface $entity
5757
*
@@ -67,7 +67,7 @@ public function remove(StateInterface $entity): bool;
6767
public function commit(): mixed;
6868

6969
/**
70-
* Has Entity.
70+
* Has entity.
7171
*
7272
* @param StateInterface $entity
7373
*
@@ -76,7 +76,7 @@ public function commit(): mixed;
7676
public function has(StateInterface $entity): bool;
7777

7878
/**
79-
* Reset Mapper State.
79+
* Reset mapper state.
8080
*
8181
* @return ImportInterface
8282
*/
@@ -99,7 +99,7 @@ public function getObjects(array $opts = []): array;
9999
public function getObjectsCount(): int;
100100

101101
/**
102-
* Inject Logger.
102+
* Inject logger.
103103
*
104104
* @param LoggerInterface $logger
105105
*
@@ -130,14 +130,14 @@ public function inDryRunMode(): bool;
130130
public function inTraceMode(): bool;
131131

132132
/**
133-
* Get List Of registered pointers.
133+
* Get list of registered pointers.
134134
*
135135
* @return array
136136
*/
137137
public function getPointersList(): array;
138138

139139
/**
140-
* Get List of changed items that changed.
140+
* Get list of changed items that changed.
141141
*
142142
* @return array
143143
*/

src/Libs/Message.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
/**
88
* Volatile messaging between classes.
99
* This should not be used for anything important.
10-
* Data is mutable, and can be change by anything.
11-
* Messages are not persistent and will be removed
12-
* once the execution is done.
10+
* Data is mutable, and can be changed by anything.
11+
* Messages are not persistent and will be removed once the execution is done.
1312
*/
1413
final class Message
1514
{
1615
private static array $data = [];
1716

1817
/**
19-
* Add Message to Store.
18+
* Add message to store.
2019
*
2120
* @param string $key Message key.
2221
* @param mixed $value value.

src/Libs/QueueRequests.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
namespace App\Libs;
66

77
use Countable;
8+
use Iterator;
89
use Symfony\Contracts\HttpClient\ResponseInterface;
910

10-
final class QueueRequests implements Countable, \Iterator
11+
final class QueueRequests implements Countable, Iterator
1112
{
1213
/**
1314
* @var array<ResponseInterface> Queued Requests.

src/Libs/Router.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ private function parseFile(string $file): array|false
107107
$count = count($tokens);
108108

109109
foreach ($tokens as $i => $iValue) {
110-
if ($iValue->getTokenName() === 'T_NAMESPACE') {
110+
if ('T_NAMESPACE' === $iValue->getTokenName()) {
111111
for ($j = $i + 1; $j < $count; $j++) {
112-
if ($tokens[$j]->getTokenName() === 'T_NAME_QUALIFIED') {
112+
if ('T_NAME_QUALIFIED' === $tokens[$j]->getTokenName()) {
113113
$namespace = $tokens[$j]->text;
114114
break;
115115
}
116116
}
117117
}
118118

119-
if ($iValue->getTokenName() === 'T_CLASS') {
119+
if ('T_CLASS' === $iValue->getTokenName()) {
120120
for ($j = $i + 1; $j < $count; $j++) {
121-
if ($tokens[$j]->getTokenName() === 'T_WHITESPACE') {
121+
if ('T_WHITESPACE' === $tokens[$j]->getTokenName()) {
122122
continue;
123123
}
124124

125-
if ($tokens[$j]->getTokenName() === 'T_STRING') {
125+
if ('T_STRING' === $tokens[$j]->getTokenName()) {
126126
$classes[] = $namespace . '\\' . $tokens[$j]->text;
127127
} else {
128128
break;

0 commit comments

Comments
 (0)