Passed
Push — master ( 641929...562012 )
by Alexey
06:04 queued 12s
created

ConsoleLog   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A log() 0 6 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) Ne-Lexa
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/google-play-scraper
12
 */
13
14
namespace Nelexa\GPlay\HttpClient;
15
16
use Psr\Log\AbstractLogger;
17
use Psr\Log\LogLevel;
18
19
class ConsoleLog extends AbstractLogger
20
{
21 60
    public function log($level, $message, array $context = []): void
22
    {
23 60
        $stream = LogLevel::DEBUG === $level || LogLevel::INFO === $level ? \STDOUT : \STDERR;
24 60
        fwrite($stream, '[' . strtoupper($level) . '] ' . $message . \PHP_EOL);
25 60
        if (!empty($context)) {
26
            fwrite($stream, var_export($context, true) . \PHP_EOL);
27
        }
28
    }
29
}
30