Completed
Push — master ( 1a01ba...b462f9 )
by Freek
03:37 queued 01:58
created

HandlesEvents   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 17
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handlesEvent() 0 4 1
A methodNameThatHandlesEvent() 0 4 1
A handleException() 0 4 1
1
<?php
2
3
namespace Spatie\EventProjector\EventHandlers;
4
5
use Exception;
6
7
trait HandlesEvents
8
{
9
    public function handlesEvent(object $event): bool
10
    {
11
        return array_key_exists(get_class($event), $this->handlesEvents);
0 ignored issues
show
Bug introduced by
The property handlesEvents does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
12
    }
13
14
    public function methodNameThatHandlesEvent(object $event): string
15
    {
16
        return $this->handlesEvents[get_class($event)] ?? '';
17
    }
18
19
    public function handleException(Exception $exception)
0 ignored issues
show
Unused Code introduced by
The parameter $exception is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
22
    }
23
}
24