AggregateChildEventExceptionFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 12 1
A canFormat() 0 4 1
1
<?php
2
namespace Workana\AsyncJobs\Formatter;
3
4
use Workana\AsyncJobs\EventDispatching\AggregateChildEventException;
5
6
/**
7
 * @author Carlos Frutos <[email protected]>
8
 */
9
class AggregateChildEventExceptionFormatter extends AggregateFormatterAware
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function format($target)
15
    {
16
        $wrapped = $target->getWrappedError();
17
        return strtr('Failed event :event on listener :listener with ":message". File :file line :line (:type)', [
18
            ':event' =>  $target->getEventName(),
19
            ':listener' => $target->getListenerName(),
20
            ':message' => $wrapped->getMessage(),
21
            ':file' => $wrapped->getFile(),
22
            ':line' => $wrapped->getLine(),
23
            ':type' => get_class($wrapped),
24
        ]);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function canFormat($target)
31
    {
32
        return ($target instanceof AggregateChildEventException);
33
    }
34
}