Skip to content

Commit

Permalink
Added debug option on Weakness command
Browse files Browse the repository at this point in the history
  • Loading branch information
DeGraciaMathieu committed Oct 28, 2024
1 parent e2405f3 commit fd819b7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Application/Weakness/WeaknessAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function execute(WeaknessRequest $request, WeaknessPresenter $presenter):
);

} catch (Throwable $e) {
$presenter->error($e->getMessage());
$presenter->error($e);
}
}
}
3 changes: 2 additions & 1 deletion app/Application/Weakness/WeaknessPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace App\Application\Weakness;

use Throwable;
use App\Application\Weakness\WeaknessResponse;

interface WeaknessPresenter
{
public function hello(): void;
public function present(WeaknessResponse $response): void;
public function error(string $message): void;
public function error(Throwable $exception): void;
}
9 changes: 7 additions & 2 deletions app/Presenter/Commands/Weakness/Summary/SummaryPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Presenter\Commands\Weakness\Summary;

use Throwable;
use function Laravel\Prompts\info;
use function Laravel\Prompts\alert;
use App\Application\Weakness\WeaknessResponse;
Expand All @@ -23,11 +24,15 @@ public function hello(): void
info('❀ PHP Class Dependencies Analyzer ❀');
}

public function error(string $message): void
public function error(Throwable $exception): void
{
alert('sorry, something went wrong');

alert($message);
if ($this->settings->debug()) {
alert($exception);
}

alert($exception->getMessage());
}

public function present(WeaknessResponse $response): void
Expand Down
6 changes: 6 additions & 0 deletions app/Presenter/Commands/Weakness/Summary/SummarySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SummarySettings
public function __construct(
private readonly ?int $limit = null,
private readonly ?float $minDelta = null,
private readonly bool $debug = false,
) {}

public function limit(): ?int
Expand All @@ -18,4 +19,9 @@ public function minDelta(): float
{
return $this->minDelta ?? 0.0;
}

public function debug(): bool
{
return $this->debug;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static function make(WeaknessCommand $command): SummarySettings
return new SummarySettings(
limit: $command->option('limit') ?? null,
minDelta: $command->option('min-delta') ?? null,
debug: $command->option('debug') ?? false,
);
}
}
Binary file modified builds/class-dependencies-analyzer
Binary file not shown.

0 comments on commit fd819b7

Please sign in to comment.