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

Logger   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 28
rs 10
ccs 18
cts 18
cp 1
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A logProcess() 0 14 3
A setLogger() 0 3 1
A log() 0 5 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