Passed
Pull Request — main (#123)
by Andrey
58:10 queued 43:14
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 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