Completed
Pull Request — stable (#353)
by Matt
04:33
created

Installer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 27
dl 0
loc 41
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A install() 0 21 2
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
    public function install(): void
43
    {
44
        $this->require('illuminate/log "5.8.*"');
45
46
        $this->task(
47
            'Creating default logging configuration',
48
            function () {
49
                if (! File::exists(config_path('logging.php'))) {
50
                    return File::copy(
51
                        static::CONFIG_FILE,
52
                        $this->app->configPath('logging.php')
53
                    );
54
                }
55
56
                return false;
57
            }
58
        );
59
60
        $this->info('Usage:');
61
        $this->comment(
62
            '
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
    }
76
}
77