Installer::install()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 21
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2.0017

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 21
ccs 12
cts 13
cp 0.9231
rs 9.552
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 2.0017
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Laravel Zero.
7
 *
8
 * (c) Nuno Maduro <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace LaravelZero\Framework\Components\Log;
15
16
use Illuminate\Support\Facades\File;
17
use LaravelZero\Framework\Components\AbstractInstaller;
18
19
/**
20
 * @internal
21
 */
22
final class Installer extends AbstractInstaller
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected $name = 'install:log';
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    protected $description = 'Log: Robust logging services';
33
34
    /**
35
     * The config file path.
36
     */
37
    private const CONFIG_FILE = __DIR__.DIRECTORY_SEPARATOR.'stubs'.DIRECTORY_SEPARATOR.'logging.php';
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function install(): void
43
    {
44 2
        $this->require('illuminate/log "^6.0"');
45
46 2
        $this->task(
47 2
            'Creating default logging configuration',
48
            function () {
49 2
                if (! File::exists(config_path('logging.php'))) {
50 2
                    return File::copy(
51 2
                        static::CONFIG_FILE,
52 2
                        $this->app->configPath('logging.php')
53
                    );
54
                }
55
56
                return false;
57 2
            }
58
        );
59
60 2
        $this->info('Usage:');
61 2
        $this->comment(
62 2
            '
63
use Log;
64
65
Log::emergency($message);
66
Log::alert($message);
67
Log::critical($message);
68
Log::error($message);
69
Log::warning($message);
70
Log::notice($message);
71
Log::info($message);
72
Log::debug($message);
73
'
74
        );
75 2
    }
76
}
77