Completed
Push — master ( 743f45...5838ba )
by Freek
01:51
created

InvalidEventHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A eventHandlingMethodDoesNotExist() 0 7 1
A doesNotExist() 0 4 1
1
<?php
2
3
namespace Spatie\EventProjector\Exceptions;
4
5
use Exception;
6
use Spatie\EventProjector\ShouldBeStored;
7
use Spatie\EventProjector\EventHandlers\EventHandler;
8
9
class InvalidEventHandler extends Exception
10
{
11
    public static function eventHandlingMethodDoesNotExist(object $eventHandler, ShouldBeStored $event, string $methodName)
12
    {
13
        $eventHandlerClass = get_class($eventHandler);
14
        $eventClass = get_class($event);
15
16
        return new static("Tried to call `$methodName` on `$eventHandlerClass` to handle an event of class `$eventClass` but that method does not exist.");
17
    }
18
19
    public static function doesNotExist(string $eventHandlerClass)
20
    {
21
        return new static("The event handler class `{$eventHandlerClass}` does not exist.");
22
    }
23
}
24