Completed
Pull Request — master (#5)
by Timothée
03:28
created

ClassNameFormatter::propertiesUsed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
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
    public function propertiesUsed($command)
30
    {
31
        return [];
32
    }
33
34
    /**
35
     * @param object $command
36
     * @param Exception $e
37
     * @return string|null
38
     */
39
    public function commandFailed($command, Exception $e)
40
    {
41
        $commandClass = get_class($command);
42
        $exceptionClass = get_class($e);
43
        $exceptionMessage = $e->getMessage();
44
45
        return "Command failed: {$commandClass} threw the exception {$exceptionClass} ({$exceptionMessage})";
46
    }
47
}
48