Test Failed
Push — feature-laravel-5.4 ( 1c0ad8...11ab58 )
by Kirill
04:08
created

AppServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 42.55 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 20
loc 47
rs 10
wmc 7
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 1
A loadProductionProviders() 10 10 3
A loadLocalProviders() 10 10 3

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
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Providers;
12
13
use App\Models\Tip\ContentObserver;
14
use Illuminate\Config\Repository;
15
use Illuminate\Foundation\Application;
16
use Illuminate\Support\ServiceProvider;
17
use Service\ContentRenderer\ContentRendererInterface;
18
use Service\ContentRenderer\RenderersRepository;
19
20
/**
21
 * Class AppServiceProvider.
22
 */
23
class AppServiceProvider extends ServiceProvider
24
{
25
    /**
26
     * @var Application
27
     */
28
    protected $app;
29
30
    /**
31
     * @retrun void
32
     * @throws \InvalidArgumentException?query=is%3Aresolved
33
     */
34
    public function register(): void
35
    {
36
        $this->loadLocalProviders($this->app->make(Repository::class));
37
        $this->loadProductionProviders($this->app->make(Repository::class));
38
    }
39
40
    /**
41
     * @param Repository $repository
42
     * @return void
43
     */
44 View Code Duplication
    private function loadProductionProviders(Repository $repository): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
45
    {
46
        if (!$this->app->isLocal()) {
47
            $providers = (array) $repository->get('app.production_providers', []);
48
49
            foreach ($providers as $provider) {
50
                $this->app->register($provider);
51
            }
52
        }
53
    }
54
55
    /**
56
     * @param  Repository $repository
57
     * @return void
58
     */
59 View Code Duplication
    private function loadLocalProviders(Repository $repository): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
60
    {
61
        if ($this->app->isLocal()) {
62
            $providers = (array) $repository->get('app.local_providers', []);
63
64
            foreach ($providers as $provider) {
65
                $this->app->register($provider);
66
            }
67
        }
68
    }
69
}
70