Completed
Pull Request — master (#3)
by Mihail
10:52
created

Cli   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 5
b 0
f 0
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 3 1
A __construct() 0 4 2
1
<?php
2
3
/*
4
 * This file is part of the Koded package.
5
 *
6
 * (c) Mihail Binev <[email protected]>
7
 *
8
 * Please view the LICENSE distributed with this source code
9
 * for the full copyright and license information.
10
 *
11
 */
12
13
namespace Koded\Logging\Processors;
14
15
/**
16
 * Log processor for CLI.
17
 *
18
 */
19
class Cli extends Processor
20
{
21
    protected string $format = '> [timestamp][levelname] - message';
22
23
    /** @var resource */
24
    private $handle;
25
26
    public function __construct(array $settings)
27 1
    {
28
        parent::__construct($settings);
29 1
        $this->handle = \defined('STDERR') ? STDERR : \fopen('php://stderr', 'w');
30 1
    }
31 1
32
    protected function process(array $message): void
33 1
    {
34
        \fwrite($this->handle, \strtr($this->format, $message) . PHP_EOL);
35 1
    }
36
}
37