Passed
Push — 9.x ( facc1a...80dc3b )
by Andrey
13:27
created

Logger::logProcess()   B

Complexity

Conditions 9
Paths 10

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 17
nc 10
nop 1
dl 0
loc 25
rs 8.0555
c 0
b 0
f 0
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
    protected function setLogger(): void
11
    {
12
        Service::io($this->output);
13
    }
14
15
    protected function log(...$message): void
16
    {
17
        $value = $this->logProcess($message);
18
19
        Log::write($value);
20
    }
21
22
    protected function logProcess(array $values): string
23
    {
24
        foreach ($values as &$value) {
25
            switch (gettype($value)) {
26
                case 'boolean':
27
                case 'bool':
28
                    $value = $value ? '"true"' : '"false"';
29
                    break;
30
31
                case 'integer':
32
                case 'double':
33
                    $value = '"' . $value . '"';
34
                    break;
35
36
                case 'array':
37
                    $value = implode(', ', $value);
38
                    break;
39
40
                case 'NULL':
41
                    $value = '"null"';
42
                    break;
43
            }
44
        }
45
46
        return implode(' ', $values);
47
    }
48
}
49