ExceptionFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

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