ImageServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 16.22 %

Coupling/Cohesion

Components 1
Dependencies 6
Metric Value
wmc 2
lcom 1
cbo 6
dl 6
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 6 19 1
A provides() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Modules\Media\Image;
2
3
use Illuminate\Foundation\AliasLoader;
4
use Illuminate\Support\ServiceProvider;
5
use Modules\Media\Image\Intervention\InterventionFactory;
6
7
class ImageServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Register the service provider.
11
     *
12
     * @return void
13
     */
14
    public function register()
15
    {
16
        $this->app->bind(
17
            'Modules\Media\Image\ImageFactoryInterface',
18
            'Modules\Media\Image\Intervention\InterventionFactory'
19
        );
20
21 View Code Duplication
        $this->app['imagy'] = $this->app->share(function ($app) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
            $factory = new InterventionFactory();
23
            $thumbnailManager = new ThumbnailsManager($app['config'], $app['modules']);
0 ignored issues
show
Unused Code introduced by
The call to ThumbnailsManager::__construct() has too many arguments starting with $app['modules'].

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...
24
25
            return new Imagy($factory, $thumbnailManager, $app['config']);
26
        });
27
28
        $this->app->booting(function () {
29
            $loader = AliasLoader::getInstance();
30
            $loader->alias('Imagy', 'Modules\Media\Image\Facade\Imagy');
31
        });
32
    }
33
34
    /**
35
     * Get the services provided by the provider.
36
     *
37
     * @return array
38
     */
39
    public function provides()
40
    {
41
        return ['imagy'];
42
    }
43
}
44