Completed
Push — master ( d1f4bd...fa732c )
by Ross
8s
created

ClassNameFormatter::commandContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace League\Tactician\Logger\Formatter;
3
4
use Exception;
5
6
/**
7
 * Returns log messages only dump the Command & Exception's class names.
8
 */
9
class ClassNameFormatter implements Formatter
10
{
11
    /**
12
     * @param object $command
13
     * @return string|null
14
     */
15
    public function commandReceived($command)
16
    {
17
        return 'Command received: ' . get_class($command);
18
    }
19
20
    /**
21
     * @param object $command
22
     * @return string|null
23
     */
24
    public function commandHandled($command)
25
    {
26
        return 'Command succeeded: ' . get_class($command);
27
    }
28
29
    /**
30
     * @param object $command
31
     * @return string|null
32
     */
33
    public function commandFailed($command)
34
    {
35
        return 'Command failed: ' . get_class($command);
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function commandContext($command)
42
    {
43
        return ['class' => get_class($command)];
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function failureContext(array $currentContext, \Exception $e)
50
    {
51
        return ['error' => ['class' => get_class($e), 'message' => $e->getMessage()]] + $currentContext;
52
    }
53
}
54