LaravelToonServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 0
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Squareetlabs\LaravelToon;
6
7
use Illuminate\Support\ServiceProvider;
8
use Squareetlabs\LaravelToon\Console\Commands\ToonAnalyzeCommand;
9
use Squareetlabs\LaravelToon\Console\Commands\ToonBenchmarkCommand;
10
use Squareetlabs\LaravelToon\Console\Commands\ToonConvertCommand;
11
use Squareetlabs\LaravelToon\Console\Commands\ToonDashboardCommand;
0 ignored issues
show
Bug introduced by
The type Squareetlabs\LaravelToon...ds\ToonDashboardCommand was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Squareetlabs\LaravelToon\Services\CompressionMetrics;
13
use Squareetlabs\LaravelToon\Services\CostCalculator;
0 ignored issues
show
Bug introduced by
The type Squareetlabs\LaravelToon\Services\CostCalculator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Squareetlabs\LaravelToon\Services\TokenAnalyzer;
15
use Squareetlabs\LaravelToon\Services\ToonService;
16
17
class LaravelToonServiceProvider extends ServiceProvider
18
{
19
    /**
20
     * Servicios principales de LaravelToon.
21
     */
22
    public function register(): void
23
    {
24
        $this->mergeConfigFrom(
25
            __DIR__.'/../config/laravel-toon.php',
26
            'laravel-toon'
27
        );
28
29
        // Registrar servicios principales
30
        $this->app->singleton('toon', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
        $this->app->singleton('toon', function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
            return new ToonService();
32
        });
33
34
        $this->app->singleton(ToonService::class, function ($app) {
35
            return $app->make('toon');
36
        });
37
38
        $this->app->singleton(TokenAnalyzer::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
        $this->app->singleton(TokenAnalyzer::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
            return new TokenAnalyzer();
40
        });
41
42
        $this->app->singleton(CompressionMetrics::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
        $this->app->singleton(CompressionMetrics::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
            return new CompressionMetrics();
44
        });
45
46
        $this->app->singleton(CostCalculator::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

46
        $this->app->singleton(CostCalculator::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
            return new CostCalculator(config('laravel-toon.cost_calculation.models', []));
48
        });
49
    }
50
51
    /**
52
     * Inicializar servicios en la aplicación.
53
     */
54
    public function boot(): void
55
    {
56
        // Publicar configuración
57
        $this->publishes([
58
            __DIR__.'/../config/laravel-toon.php' => config_path('laravel-toon.php'),
59
        ], 'laravel-toon-config');
60
61
        // Registrar comandos Artisan
62
        if ($this->app->runningInConsole()) {
63
            $this->commands([
64
                ToonConvertCommand::class,
65
                ToonAnalyzeCommand::class,
66
                ToonBenchmarkCommand::class,
67
                ToonDashboardCommand::class,
68
            ]);
69
        }
70
    }
71
}
72
73