Passed
Push — 10.x ( d6d64f...175d11 )
by Andrey
13:22
created

Logger::setLogger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 2
cts 2
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 18
    protected function setLogger(): void
11
    {
12 18
        Service::io($this->output);
13 18
    }
14
15 24
    protected function log(...$message): void
16
    {
17 24
        $value = $this->logProcess($message);
18
19 24
        Log::write($value);
20 24
    }
21
22 24
    protected function logProcess(array $values): string
23
    {
24 24
        foreach ($values as &$value) {
25 24
            switch (gettype($value)) {
26 24
                case 'array':
27 24
                    $value = implode(', ', $value);
28 24
                    break;
29 24
30
                default:
31 24
                    $value = json_encode($value);
32 24
            }
33 15
        }
34 15
35
        return implode(' ', $values);
36 24
    }
37
}
38