Skip to content

Commit bf082e0

Browse files
better injection
1 parent ca77e0d commit bf082e0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

app/Commands/Analyze/Class/PresenterFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
class PresenterFactory
1111
{
12+
public function __construct(
13+
private readonly GraphPresenterFactory $graphPresenterFactory,
14+
private readonly SummaryPresenterFactory $summaryPresenterFactory,
15+
) {}
16+
1217
public function make(Command $command): AnalyzePresenter
1318
{
1419
return $command->option('graph')
@@ -18,11 +23,11 @@ public function make(Command $command): AnalyzePresenter
1823

1924
private function makeGraphPresenter(Command $command): AnalyzePresenter
2025
{
21-
return app(GraphPresenterFactory::class)->make($command);
26+
return $this->graphPresenterFactory->make($command);
2227
}
2328

2429
private function makeSummaryPresenter(Command $command): AnalyzePresenter
2530
{
26-
return app(SummaryPresenterFactory::class)->make($command);
31+
return $this->summaryPresenterFactory->make($command);
2732
}
2833
}

app/Commands/Analyze/Component/Factories/PresenterFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
class PresenterFactory
1111
{
12+
public function __construct(
13+
private readonly GraphPresenterFactory $graphPresenterFactory,
14+
private readonly SummaryPresenterFactory $summaryPresenterFactory,
15+
) {}
16+
1217
public function make(Command $command): AnalyzePresenter
1318
{
1419
return $command->option('graph')
@@ -18,11 +23,11 @@ public function make(Command $command): AnalyzePresenter
1823

1924
private function makeGraphPresenter(Command $command): AnalyzePresenter
2025
{
21-
return app(GraphPresenterFactory::class)->make($command);
26+
return $this->graphPresenterFactory->make($command);
2227
}
2328

2429
private function makeSummaryPresenter(Command $command): AnalyzePresenter
2530
{
26-
return app(SummaryPresenterFactory::class)->make($command);
31+
return $this->summaryPresenterFactory->make($command);
2732
}
2833
}

0 commit comments

Comments
 (0)