DefaultWriter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A write() 0 12 1
1
<?php
2
3
namespace Faulancer\Log\Writer;
4
5
/**
6
 * Class DefaultWriter | DefaultWriter.php
7
 *
8
 * @package Faulancer\Log
9
 * @author  Florian Knapp <[email protected]>
10
 */
11
class DefaultWriter extends AbstractWriter
12
{
13
14
    /**
15
     * Write default log format
16
     *
17
     * @param string $logfile
18
     * @param string $message
19
     * @param string $level
20
     *
21
     * @return int|bool
22
     */
23
    public function write(string $logfile, string $message, string $level)
24
    {
25
        $columns = [
26
            (new \DateTime())->format('d.m.Y H:i:s'),
27
            strtoupper($level),
28
            $message
29
        ];
30
31
        $messageString  = implode(' | ', $columns) . "\r\n";
32
33
        return file_put_contents($logfile, $messageString, FILE_APPEND);
34
    }
35
36
}