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

Cli::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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