-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from DeGraciaMathieu/added-component-analyze
Added component command
- Loading branch information
Showing
109 changed files
with
2,023 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Application\Analyze; | ||
|
||
class AnalyzeMetric | ||
{ | ||
public function __construct( | ||
private readonly array $metric, | ||
) {} | ||
|
||
public function name(): string | ||
{ | ||
return $this->metric['name']; | ||
} | ||
|
||
public function dependencies(): array | ||
{ | ||
return $this->metric['dependencies']; | ||
} | ||
|
||
public function abstract(): bool | ||
{ | ||
return $this->metric['abstract']; | ||
} | ||
|
||
public function efferentCoupling(): float | ||
{ | ||
return $this->metric['coupling']['efferent']; | ||
} | ||
|
||
public function afferentCoupling(): float | ||
{ | ||
return $this->metric['coupling']['afferent']; | ||
} | ||
|
||
public function instability(): float | ||
{ | ||
return $this->metric['coupling']['instability']; | ||
} | ||
|
||
public function numberOfAbstractDependencies(): int | ||
{ | ||
return $this->metric['abstractness']['numberOfAbstractDependencies']; | ||
} | ||
|
||
public function abstractnessRatio(): float | ||
{ | ||
return $this->metric['abstractness']['ratio']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...s/Analyze/Graph/GraphPresenterFactory.php → ...yze/Class/Graph/GraphPresenterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ds/Analyze/Graph/GraphSettingsFactory.php → ...lyze/Class/Graph/GraphSettingsFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Class; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Application\Analyze\AnalyzePresenter; | ||
use App\Commands\Analyze\Class\Graph\GraphPresenterFactory; | ||
use App\Commands\Analyze\Class\Summary\SummaryPresenterFactory; | ||
|
||
class PresenterFactory | ||
{ | ||
public function __construct( | ||
private readonly GraphPresenterFactory $graphPresenterFactory, | ||
private readonly SummaryPresenterFactory $summaryPresenterFactory, | ||
) {} | ||
|
||
public function make(Command $command): AnalyzePresenter | ||
{ | ||
return $command->option('graph') | ||
? $this->makeGraphPresenter($command) | ||
: $this->makeSummaryPresenter($command); | ||
} | ||
|
||
private function makeGraphPresenter(Command $command): AnalyzePresenter | ||
{ | ||
return $this->graphPresenterFactory->make($command); | ||
} | ||
|
||
private function makeSummaryPresenter(Command $command): AnalyzePresenter | ||
{ | ||
return $this->summaryPresenterFactory->make($command); | ||
} | ||
} |
12 changes: 6 additions & 6 deletions
12
...alyze/Summary/SummaryPresenterFactory.php → ...Class/Summary/SummaryPresenterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nalyze/Summary/SummarySettingsFactory.php → .../Class/Summary/SummarySettingsFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
app/Commands/Analyze/TransformerFactory.php → ...ands/Analyze/Class/TransformerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Component; | ||
|
||
use App\Commands\AbstractCommand; | ||
use App\Application\Analyze\AnalyzeAction; | ||
use App\Application\Analyze\AnalyzeRequest; | ||
use App\Application\Analyze\AnalyzePresenter; | ||
use App\Commands\Analyze\Component\Factories\PresenterFactory; | ||
|
||
class ComponentCommand extends AbstractCommand | ||
{ | ||
protected $signature = 'analyze:component {path} {components} | ||
{--graph} | ||
{--debug} | ||
{--info} | ||
{--human-readable : Display human readable metrics} | ||
'; | ||
|
||
protected $description = ''; | ||
|
||
public function handle(AnalyzeAction $action): void | ||
{ | ||
$action->execute( | ||
request: $this->makeRequest(), | ||
presenter: $this->makePresenter(), | ||
); | ||
} | ||
|
||
private function makeRequest(): AnalyzeRequest | ||
{ | ||
return new AnalyzeRequest( | ||
path: $this->argument('path'), | ||
); | ||
} | ||
|
||
private function makePresenter(): AnalyzePresenter | ||
{ | ||
return app(PresenterFactory::class)->make($this); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/Commands/Analyze/Component/Factories/PresenterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Component\Factories; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Application\Analyze\AnalyzePresenter; | ||
use App\Commands\Analyze\Component\Graph\GraphPresenterFactory; | ||
use App\Commands\Analyze\Component\Summary\SummaryPresenterFactory; | ||
|
||
class PresenterFactory | ||
{ | ||
public function __construct( | ||
private readonly GraphPresenterFactory $graphPresenterFactory, | ||
private readonly SummaryPresenterFactory $summaryPresenterFactory, | ||
) {} | ||
|
||
public function make(Command $command): AnalyzePresenter | ||
{ | ||
return $command->option('graph') | ||
? $this->makeGraphPresenter($command) | ||
: $this->makeSummaryPresenter($command); | ||
} | ||
|
||
private function makeGraphPresenter(Command $command): AnalyzePresenter | ||
{ | ||
return $this->graphPresenterFactory->make($command); | ||
} | ||
|
||
private function makeSummaryPresenter(Command $command): AnalyzePresenter | ||
{ | ||
return $this->summaryPresenterFactory->make($command); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Commands/Analyze/Component/Factories/TransformerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Component\Factories; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
use App\Presenter\Analyze\Shared\Filters\Contracts\Transformer; | ||
use App\Presenter\Analyze\Shared\Filters\Transformers\ComponentTransformer; | ||
|
||
class TransformerFactory | ||
{ | ||
public static function make(Command $command): Transformer | ||
{ | ||
return app(ComponentTransformer::class, [ | ||
'targetedComponents' => $command->argumentToList('components'), | ||
]); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/Commands/Analyze/Component/Graph/GraphPresenterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Component\Graph; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
use App\Application\Analyze\AnalyzePresenter; | ||
use App\Presenter\Analyze\Component\Graph\GraphView; | ||
use App\Presenter\Analyze\Component\Graph\GraphMapper; | ||
use App\Presenter\Analyze\Component\Graph\GraphPresenter; | ||
use App\Commands\Analyze\Component\Graph\GraphSettingsFactory; | ||
use App\Commands\Analyze\Component\Factories\TransformerFactory; | ||
|
||
class GraphPresenterFactory | ||
{ | ||
public function __construct( | ||
private readonly GraphView $view, | ||
private readonly GraphMapper $mapper, | ||
private readonly TransformerFactory $transformerFactory, | ||
private readonly GraphSettingsFactory $settingsFactory, | ||
) {} | ||
|
||
public function make(Command $command): AnalyzePresenter | ||
{ | ||
return new GraphPresenter( | ||
view: $this->view, | ||
mapper: $this->mapper, | ||
transformer: $this->transformerFactory->make($command), | ||
settings: $this->settingsFactory->make($command), | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/Commands/Analyze/Component/Graph/GraphSettingsFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Commands\Analyze\Component\Graph; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
use App\Presenter\Analyze\Component\Graph\GraphSettings; | ||
|
||
class GraphSettingsFactory | ||
{ | ||
public function make(Command $command): GraphSettings | ||
{ | ||
return new GraphSettings( | ||
components: $command->argumentToList('components'), | ||
info: $command->option('info'), | ||
debug: $command->option('debug'), | ||
); | ||
} | ||
} |
Oops, something went wrong.