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

HandlesEvents::subscribe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 9.6666
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