Cli   A
last analyzed

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 5
c 5
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
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
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