Completed
Push — master ( 051415...d021c6 )
by Sebastian
05:18
created

HandlesEvents   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A subscribe() 0 9 1
1
<?php
2
3
namespace App\Services\Events;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use ReflectionClass;
7
8
trait HandlesEvents
9
{
10
    protected $events = [];
11
12
    public function subscribe(Dispatcher $dispatcher)
13
    {
14
        collect($this->events)->each(function (string $event) use ($dispatcher) {
15
            $dispatcher->listen(
16
                $event,
17
                static::class . '@' . (new ReflectionClass($event))->getShortName()
18
            );
19
        });
20
    }
21
}
22