Completed
Push — master ( 40c839...4a6871 )
by Flo
05:59
created

DefaultWriter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

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
     * @inheritdoc
18
     * @return int|bool
19
     */
20
    public function write(string $logfile, string $message, string $level)
21
    {
22
        $columns = [
23
            (new \DateTime())->format('d.m.Y H:i:s'),
24
            strtoupper($level),
25
            $message
26
        ];
27
28
        $messageString  = implode(' | ', $columns) . "\r\n";
29
30
        return file_put_contents($logfile, $messageString, FILE_APPEND);
31
    }
32
33
}