Cli::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 2
c 3
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
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
use function defined;
16
use function fopen;
17
use function fwrite;
18
use function strtr;
19
20
/**
21
 * Log processor for CLI.
22
 *
23
 */
24
class Cli extends Processor
25
{
26
    protected string $format = '> [timestamp][levelname] message';
27 1
28
    /** @var resource */
29 1
    private $handle;
30 1
31 1
    public function __construct(array $settings)
32
    {
33 1
        parent::__construct($settings);
34
        $this->handle = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
35 1
    }
36 1
37
    protected function process(array $message): void
38 1
    {
39
        fwrite($this->handle, strtr($this->format, $message) . PHP_EOL);
40
    }
41
}
42