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

HandlesEvents::handleException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 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