1 | <?php |
||
38 | class DummyHandler implements HandlerInterface |
||
39 | { |
||
40 | |||
41 | /** |
||
42 | * The log level we want to use. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $logLevel; |
||
47 | |||
48 | /** |
||
49 | * The available log levels. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $logLevels; |
||
54 | |||
55 | /** |
||
56 | * The formatter instance. |
||
57 | * |
||
58 | * @var \AppserverIo\Logger\Formatters\FormatterInterface |
||
59 | */ |
||
60 | protected $formatter; |
||
61 | |||
62 | /** |
||
63 | * Initializes the handler instance with channel name and log level. |
||
64 | * |
||
65 | * @param integer $logLevel The log level we want to use |
||
66 | */ |
||
67 | 10 | public function __construct($logLevel = LogLevel::INFO) |
|
77 | |||
78 | /** |
||
79 | * Sets the formatter for this handler. |
||
80 | * |
||
81 | * @param \AppserverIo\Logger\Formatters\FormatterInterface $formatter The formatter instance |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function setFormatter(FormatterInterface $formatter) |
||
89 | |||
90 | /** |
||
91 | * Returns the formatter for this handler. |
||
92 | * |
||
93 | * @return \AppserverIo\Logger\Formatters\FormatterInterface The formatter instance |
||
94 | */ |
||
95 | 6 | public function getFormatter() |
|
99 | |||
100 | /** |
||
101 | * Handles the log message. |
||
102 | * |
||
103 | * @param \AppserverIo\Logger\LogMessageInterface $logMessage The message to be handled |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | 2 | public function handle(LogMessageInterface $logMessage) |
|
111 | |||
112 | /** |
||
113 | * Returns the log level we want to use. |
||
114 | * |
||
115 | * @return integer The log level |
||
116 | */ |
||
117 | 6 | protected function getLogLevel() |
|
121 | |||
122 | /** |
||
123 | * Returns TRUE if the handler should log a message based on the actual |
||
124 | * log level, else FALSE. |
||
125 | * |
||
126 | * @param string $level The log level to query |
||
127 | * |
||
128 | * @return boolean TRUE if the handler should log |
||
129 | */ |
||
130 | 6 | protected function shouldLog($level) |
|
134 | } |
||
135 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.