patrickbrouwers / phpinsights

Code quality insights for PHP projects/libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Insights

Build Status Total Downloads Latest Version License

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!

Create a new Insight

Imagine that you want to create a new Insight that don't allow the usage of final classes:

  1. 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';
    }
}
  1. Attach the Insight to a specific inside Domain/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.

About

Code quality insights for PHP projects/libraries

License:MIT License


Languages

Language:PHP 100.0%