PHP Insights created and maintained by Nuno Maduro, is the perfect starting point to analyze the code quality of your PHP projects. Carefully crafted to simplify the analysis of your code directly on your terminal.
π¨ This project is under development. Don't use it!.
β¨ Features
- Analysis of lines of code and cyclomatic complexity
- Beautiful overview of your code structure and it's dependencies
- Contains built-in checks for making code reliable, loosely coupled, simple, and clean
ππ» Installation & Usage
Requires:
First, install PHP Insights via the Composer package manager:
composer require nunomaduro/phpinsights:dev-feat/first
Without frameworks
Use the phpinsights
binary:
php ./vendor/bin/phpinsights
Within Laravel
You can publish the config-file with:
php artisan vendor:publish --provider="NunoMaduro\PhpInsights\Application\Adapters\Laravel\InsightsServiceProvider"
Open config/insights.php
, and update the preset to laravel
.
Use the insights
Artisan command:
php artisan insights
π‘ How to contribute
The project is under development. As such, any help is welcome!
Insight
Create a new Imagine that you want to create a new Insight
that don't allow the usage of final classes:
- Create a new file under
Domain\Insights
with the content:
final class ForbiddenFinalClasses extends Insight
{
/**
* {@inheritdoc}
*/
public function hasIssue(): bool
{
return (bool) count($this->collector->getConcreteFinalClasses());
}
/**
* {@inheritdoc}
*/
public function getTitle(): string
{
return 'The use of `final` classes is prohibited';
}
}
- Attach the
Insight
to a specific insideDomain/Metrics/
:
final class ClassesFinal implements HasValue, HasPercentage, HasInsights
{
// ...
/**
* {@inheritdoc}
*/
public function getInsights(): array
{
return [
ForbiddenFinalClasses::class,
];
}
}
π License
PHP Insights is an open-sourced software licensed under the MIT license.