Skip to content

Commit ccc25ce

Browse files
Adds bubble chart visualization option
Implements a new bubble chart visualization option for class analysis. This commit introduces a new `--bubble` option to the `analyze:class` command, providing an alternative visual representation of class metrics. It includes: - A `BubblePresenterFactory` to create `BubblePresenter` instances. - A `BubblePresenter` to handle the presentation logic for the bubble chart (currently outputs metrics using `dd()`). - Updates to `PresenterFactory` to select the appropriate presenter based on the `--bubble` option.
1 parent 75e58ac commit ccc25ce

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

app/Commands/Analyze/Class/AnalyzeCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class AnalyzeCommand extends AbstractCommand
1111
{
1212
protected $signature = 'analyze:class {path}
1313
{--graph}
14+
{--bubble}
1415
{--only=}
1516
{--exclude=}
1617
{--target=}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Commands\Analyze\Class\Graph;
4+
5+
use LaravelZero\Framework\Commands\Command;
6+
use App\Presenter\Analyze\Class\Bubble\BubblePresenter;
7+
8+
class BubblePresenterFactory
9+
{
10+
public function __construct(
11+
) {}
12+
13+
public function make(Command $command): BubblePresenter
14+
{
15+
return new BubblePresenter();
16+
}
17+
}

app/Commands/Analyze/Class/PresenterFactory.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,31 @@
55
use Illuminate\Console\Command;
66
use App\Application\Analyze\AnalyzePresenter;
77
use App\Commands\Analyze\Class\Graph\GraphPresenterFactory;
8+
use App\Commands\Analyze\Class\Graph\BubblePresenterFactory;
89
use App\Commands\Analyze\Class\Summary\SummaryPresenterFactory;
910

1011
class PresenterFactory
1112
{
1213
public function __construct(
14+
private readonly BubblePresenterFactory $bubblePresenterFactory,
1315
private readonly GraphPresenterFactory $graphPresenterFactory,
1416
private readonly SummaryPresenterFactory $summaryPresenterFactory,
1517
) {}
1618

1719
public function make(Command $command): AnalyzePresenter
1820
{
19-
return $command->option('graph')
20-
? $this->makeGraphPresenter($command)
21-
: $this->makeSummaryPresenter($command);
21+
return match ($command->option('bubble')) {
22+
true => $this->makeBubblePresenter($command),
23+
false => match ($command->option('graph')) {
24+
true => $this->makeGraphPresenter($command),
25+
false => $this->makeSummaryPresenter($command),
26+
},
27+
};
28+
}
29+
30+
private function makeBubblePresenter(Command $command): AnalyzePresenter
31+
{
32+
return $this->bubblePresenterFactory->make($command);
2233
}
2334

2435
private function makeGraphPresenter(Command $command): AnalyzePresenter
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Presenter\Analyze\Class\Bubble;
4+
5+
use Exception;
6+
use Throwable;
7+
use App\Application\Analyze\AnalyzeResponse;
8+
use App\Application\Analyze\AnalyzePresenter;
9+
10+
class BubblePresenter implements AnalyzePresenter
11+
{
12+
public function present(AnalyzeResponse $response): void
13+
{
14+
$metrics = $response->metrics;
15+
16+
dd($metrics);
17+
18+
//
19+
}
20+
21+
public function hello(): void
22+
{
23+
throw new Exception('Not implemented');
24+
}
25+
26+
public function error(Throwable $e): void
27+
{
28+
throw new \Exception('Not implemented');
29+
}
30+
}

0 commit comments

Comments
 (0)