Skip to content

Commit

Permalink
Switches to dumps for easier to understand "logging"
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 26, 2023
1 parent 0a30f52 commit e2a974c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
6 changes: 1 addition & 5 deletions src/Http/Controllers/WorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function index(): JsonResponse
{
$directory = $this->app->basePath('tests/Blitz');

error_log("\n----------\n" . $directory . "\n----------");

$files = array_map(
fn (string $file) => new SplFileInfo($directory . '/' . $file),
array_values(
Expand All @@ -48,12 +46,10 @@ public function index(): JsonResponse
),
);

error_log("\n----------\n" . json_encode(array_map(fn (SplFileInfo $file) => [$file->getPathname()], $files), true) . "\n----------");
dump($files);

$workflows = array_map(fn (SplFileInfo $file) => Workflow::fromFile($file)->className(), $files);

error_log("\n----------\n" . json_encode($workflows, true) . "\n----------");

return $this->response->json($workflows);
}
}
22 changes: 2 additions & 20 deletions src/Support/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(
public readonly string $name,
public readonly string $path,
) {
dump($name, $path);
}

/**
Expand All @@ -38,14 +39,6 @@ public function __construct(
*/
public static function fromFile(SplFileInfo $file): static
{
error_log("\n----------\n" . ucfirst(
strtolower(
implode(' ', preg_split('/(?=\p{Lu})/u', strstr($file->getFilename(), 'Test.php', true), -1, PREG_SPLIT_NO_EMPTY)),
),
) . "\n----------");

error_log("\n----------\n" . $file->getPathname() . "\n----------");

return new static(
name: ucfirst(
strtolower(
Expand All @@ -63,18 +56,7 @@ public static function fromFile(SplFileInfo $file): static
*/
public function className(): string
{
error_log("\n----------\n" . base_path() . "\n----------");
error_log("\n----------\n" . $this->path . "\n----------");

error_log("\n----------\n" . str_replace(
['/', '.php'],
['\\', ''],
ucfirst(
array_reverse(
explode(base_path(), $this->path, 2)
)[0],
),
) . "\n----------");
dump(base_path(), $this->path, explode(base_path(), $this->path, 2));

return str_replace(
['/', '.php'],
Expand Down

0 comments on commit e2a974c

Please sign in to comment.