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

ClassNameFormatter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 5
c 5
b 0
f 0
lcom 0
cbo 0
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A commandReceived() 0 4 1
A commandHandled() 0 4 1
A commandFailed() 0 4 1
A commandContext() 0 4 1
A failureContext() 0 4 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