Completed
Push — stable ( ef4570...c41d70 )
by Nuno
03:23
created

Installer::install()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 34
Code Lines 13

Duplication

Lines 10
Ratio 29.41 %

Code Coverage

Tests 13
CRAP Score 2.0014

Importance

Changes 0
Metric Value
dl 10
loc 34
ccs 13
cts 14
cp 0.9286
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 13
nc 1
nop 0
crap 2.0014
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelZero\Framework\Components\Log;
13
14
use Illuminate\Support\Facades\File;
15
use LaravelZero\Framework\Components\AbstractInstaller;
16
17
/**
18
 * This is the Laravel Zero Framework Log Component Installer Implementation.
19
 */
20
class Installer extends AbstractInstaller
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected $name = 'install:log';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected $description = 'Installs illuminate/log';
31
32
    /**
33
     * The config file path.
34
     */
35
    const CONFIG_FILE = __DIR__.DIRECTORY_SEPARATOR.'stubs'.DIRECTORY_SEPARATOR.'logging.php';
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function install(): void
41
    {
42 2
        $this->require('illuminate/log "5.6.*"');
43
44 2
        $this->task(
0 ignored issues
show
Documentation Bug introduced by
The method task does not exist on object<LaravelZero\Frame...mponents\Log\Installer>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
45 2
            'Creating default logging configuration',
46 View Code Duplication
            function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47 2
                if (! File::exists(config_path('logging.php'))) {
48 2
                    return File::copy(
49 2
                        static::CONFIG_FILE,
50 2
                        config_path('logging.php')
51
                    );
52
                }
53
54
                return false;
55 2
            }
56
        );
57
58 2
        $this->info('Usage:');
59 2
        $this->comment(
60 2
            '
61
use Illuminate\Support\Facades\Log;
62
63
Log::emergency($message);
64
Log::alert($message);
65
Log::critical($message);
66
Log::error($message);
67
Log::warning($message);
68
Log::notice($message);
69
Log::info($message);
70
Log::debug($message);
71
'
72
        );
73 2
    }
74
}
75