StreamsEventProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 12
loc 60
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B boot() 12 19 5

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 Anomaly\Streams\Platform;
2
3
use Illuminate\Contracts\Events\Dispatcher;
4
use Illuminate\Foundation\Support\Providers\EventServiceProvider;
5
6
/**
7
 * Class StreamsEventProvider
8
 *
9
 * @link   http://pyrocms.com/
10
 * @author PyroCMS, Inc. <[email protected]>
11
 * @author Ryan Thompson <[email protected]>
12
 */
13
class StreamsEventProvider extends EventServiceProvider
14
{
15
16
    /**
17
     * Event listeners.
18
     *
19
     * @var array
20
     */
21
    protected $listen = [
22
        'Anomaly\Streams\Platform\Application\Event\ApplicationHasLoaded' => [
23
            'Anomaly\Streams\Platform\Addon\Module\Listener\DetectActiveModule',
24
            'Anomaly\Streams\Platform\Application\Listener\CheckIfInstallerExists',
25
            'Anomaly\Streams\Platform\Ui\ControlPanel\Listener\LoadControlPanel',
26
            'Anomaly\Streams\Platform\Ui\Breadcrumb\Listener\GuessBreadcrumbs',
27
            'Anomaly\Streams\Platform\Ui\Breadcrumb\Listener\LoadBreadcrumbs',
28
            'Anomaly\Streams\Platform\Message\Listener\LoadMessageBag',
29
        ],
30
        'Anomaly\Streams\Platform\Addon\Event\AddonsHaveRegistered'       => [
31
            'Anomaly\Streams\Platform\Asset\Listener\AddAddonPaths',
32
            'Anomaly\Streams\Platform\Image\Listener\AddAddonPaths',
33
        ],
34
        'Anomaly\Streams\Platform\View\Event\ViewComposed'                => [
35
            'Anomaly\Streams\Platform\View\Listener\DecorateData',
36
            'Anomaly\Streams\Platform\View\Listener\LoadTemplateData',
37
        ],
38
        'Anomaly\Streams\Platform\View\Event\TemplateDataIsLoading'       => [
39
            'Anomaly\Streams\Platform\View\Listener\LoadGlobalData',
40
        ],
41
        'Anomaly\Streams\Platform\Addon\Plugin\Event\PluginWasRegistered' => [
42
            'Anomaly\Streams\Platform\Addon\Plugin\Listener\AddPluginToTwig',
43
        ],
44
        'Anomaly\Streams\Platform\Ui\Table\Event\TableIsQuerying'         => [
45
            'Anomaly\Streams\Platform\Ui\Table\Component\View\Listener\ApplyView',
46
            'Anomaly\Streams\Platform\Ui\Table\Component\Filter\Listener\FilterResults',
47
        ],
48
    ];
49
50
    /**
51
     * Register the application's event listeners.
52
     */
53
    public function boot()
54
    {
55 View Code Duplication
        foreach ($this->listen as $event => $listeners) {
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...
56
            foreach ($listeners as $key => $listener) {
57
                if (is_integer($listener)) {
58
                    $listener = $key;
59
                    $priority = $listener;
60
                } else {
61
                    $priority = 0;
62
                }
63
64
                app('events')->listen($event, $listener, $priority);
65
            }
66
        }
67
68
        foreach ($this->subscribe as $subscriber) {
69
            app('events')->subscribe($subscriber);
70
        }
71
    }
72
}
73