Passed
Branch master (fa2e2c)
by Chubarov
15:40 queued 12:39
created

ReportsServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 1 Features 2
Metric Value
wmc 7
c 8
b 1
f 2
lcom 1
cbo 2
dl 0
loc 69
ccs 41
cts 41
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 2
A registerRoutes() 0 10 1
A loadViews() 0 4 1
A boot() 0 10 1
A toPublish() 0 19 1
A registerCommands() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
namespace agoalofalife\Reports;
5
6
use Illuminate\Support\Facades\Route;
7
use Illuminate\Support\ServiceProvider;
8
9
10
class ReportsServiceProvider extends ServiceProvider
11
{
12 18
    public function boot()
13
    {
14 18
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
15 18
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'reports');
16 18
        $this->registerRoutes();
17 18
        $this->registerCommands();
18 18
        $this->loadViews();
19 18
        $this->mergeConfigFrom(__DIR__.'/../config/reports.php', 'reports');
20 18
        $this->toPublish();
21 18
    }
22
23 18
    public function register()
24
    {
25 18
        if (! defined('REPORTS_PATH')) {
26 1
            define('REPORTS_PATH', realpath(__DIR__.'/../'));
27
        }
28 18
    }
29
30 18
    protected function toPublish()
31
    {
32
//        $this->publishes([
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
//            __DIR__.'/../database/migrations' => database_path('migrations'),
34
//        ], 'reports-migration');
35 18
        $this->publishes([
36 18
            __DIR__.'/../config/reports.php' => config_path('reports.php'),
37 18
        ], 'reports-migration');
38 18
        $this->publishes([
39 18
            __DIR__.'/../resources/lang' => resource_path('lang/vendor/reports'),
40 18
        ], 'reports-migration');
41 18
        $this->publishes([
42 18
            REPORTS_PATH.'/public' => public_path('vendor/reports'),
43 18
        ], 'reports-assets');
44
45 18
        $this->publishes([
46 18
            __DIR__.'/../resources/assets/js/components' => base_path('resources/assets/js/components/reports'),
47 18
        ], 'reports-components');
48 18
    }
49
50
    /**
51
     * Register commands
52
     */
53 18
    protected function registerCommands() : void
54
    {
55 18
        $this->commands([
56 18
            Console\InstallCommand::class,
57
            Console\AssetsConsole::class,
58
            Console\ReportMakeCommand::class,
59
            Console\HandleReportCommand::class,
60
            Console\ParseReportsCommand::class,
61
        ]);
62 18
    }
63
64 18
    protected function registerRoutes() : void
65
    {
66 18
        Route::group([
67 18
            'prefix' => 'reports',
68
            'namespace' => 'agoalofalife\Reports\Http\Controllers',
69
            'middleware' => 'web',
70 18
        ], function () {
0 ignored issues
show
Unused Code introduced by
The call to Route::group() has too many arguments starting with function () { $this-.../../routes/web.php'); }.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
71 18
            $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
72 18
        });
73 18
    }
74 18
    protected function loadViews() : void
75
    {
76 18
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'reports');
77
    }
78
}