Passed
Pull Request — main (#123)
by Andrey
58:10 queued 43:14
created

Logger::log()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Concerns;
4
5
use Helldar\Verbose\Facades\Log;
6
use Helldar\Verbose\Services\Logger as Service;
7
8
trait Logger
9
{
10 36
    protected function setLogger(): void
11
    {
12 36
        Service::io($this->output);
13 36
    }
14
15 43
    protected function log(...$message): void
16
    {
17 43
        $value = $this->logProcess($message);
18
19 43
        Log::write($value);
20 43
    }
21
22 43
    protected function logProcess(array $values): string
23
    {
24 43
        foreach ($values as &$value) {
25 43
            switch (gettype($value)) {
26 43
                case 'array':
27 43
                    $value = implode(', ', $value);
28 43
                    break;
29 43
30
                default:
31 43
                    $value = json_encode($value);
32 43
            }
33 30
        }
34 30
35
        return implode(' ', $values);
36 43
    }
37
}
38