UnstyledLogOutputStyler::write()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Consolidation\Log;
3
4
use Symfony\Component\Console\Output\OutputInterface;
5
use Symfony\Component\Console\Style\OutputStyle;
6
7
/**
8
 * Base class that provides basic unstyled output.
9
 */
10
class UnstyledLogOutputStyler implements LogOutputStylerInterface
11
{
12
    public function createOutputWrapper(OutputInterface $output)
13
    {
14
        return $output;
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function defaultStyles()
21
    {
22
        return [];
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function style($context)
29
    {
30
        return $context;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function write($output, $message, $context)
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        $output->writeln($message);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function log($output, $level, $message, $context)
45
    {
46
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function success($output, $level, $message, $context)
53
    {
54
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function error($output, $level, $message, $context)
61
    {
62
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function warning($output, $level, $message, $context)
69
    {
70
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function note($output, $level, $message, $context)
77
    {
78
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function caution($output, $level, $message, $context)
85
    {
86
        return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
87
    }
88
89
    /**
90
     * Look up the label and message styles for the specified log level,
91
     * and use the log level as the label for the log message.
92
     */
93
    protected function formatMessageByLevel($level, $message, $context)
94
    {
95
        return " [$level] $message";
96
    }
97
}
98