ExceptionFormatter::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 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
}