Passed
Push — stable ( ad60b5...4f17a7 )
by Nuno
03:36
created

Command   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 81.48%

Importance

Changes 0
Metric Value
wmc 8
eloc 18
dl 0
loc 91
ccs 22
cts 27
cp 0.8148
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A title() 0 12 1
A call() 0 5 1
A task() 0 3 1
A setLaravel() 0 3 1
A menu() 0 3 1
A schedule() 0 2 1
A callSilent() 0 5 1
A setHidden() 0 5 1
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\Commands;
15
16
use function strlen;
17
use function str_repeat;
18
use function func_get_args;
19
use NunoMaduro\LaravelConsoleMenu\Menu;
20
use Illuminate\Console\Scheduling\Schedule;
21
use Illuminate\Console\Command as BaseCommand;
22
use LaravelZero\Framework\Providers\CommandRecorder\CommandRecorderRepository;
23
24
abstract class Command extends BaseCommand
25
{
26
    /**
27
     * Holds an instance of the app, if any.
28
     *
29
     * @var \LaravelZero\Framework\Application
30
     */
31
    protected $app;
32
33
    /**
34
     * Define the command's schedule.
35
     *
36
     * @param  \Illuminate\Console\Scheduling\Schedule $schedule
37
     * @return void
38
     */
39 34
    public function schedule(Schedule $schedule)
0 ignored issues
show
Unused Code introduced by
The parameter $schedule is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function schedule(/** @scrutinizer ignore-unused */ Schedule $schedule)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41 34
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 34
    public function setLaravel($laravel): void
47
    {
48 34
        parent::setLaravel($this->app = $laravel);
49 34
    }
50
51
    /**
52
     * Returns a menu builder.
53
     */
54
    public function menu(string $title, array $options = []): Menu
55
    {
56
        return $this->__call('menu', func_get_args());
57
    }
58
59
    /**
60
     * Performs the given task, outputs and
61
     * returns the result.
62
     */
63 15
    public function task(string $title = '', $task = null): bool
64
    {
65 15
        return $this->__call('task', func_get_args());
66
    }
67
68
    /*
69
     * Displays the given string as title.
70
     */
71 2
    public function title(string $title): Command
72
    {
73 2
        $size = strlen($title);
74 2
        $spaces = str_repeat(' ', $size);
75
76 2
        $this->output->newLine();
77 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>");
78 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$title$spaces</>");
79 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>");
80 2
        $this->output->newLine();
81
82 2
        return $this;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 1
    public function call($command, array $arguments = [])
89
    {
90 1
        resolve(CommandRecorderRepository::class)->create($command, $arguments);
91
92 1
        return parent::call($command, $arguments);
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function callSilent($command, array $arguments = [])
99
    {
100
        resolve(CommandRecorderRepository::class)->create($command, $arguments, CommandRecorderRepository::MODE_SILENT);
101
102
        return parent::callSilent($command, $arguments);
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     *
108
     * @see {https://github.com/laravel/framework/pull/27005}
109
     */
110 34
    public function setHidden($hidden)
111
    {
112 34
        parent::setHidden($this->hidden = $hidden);
113
114 34
        return $this;
115
    }
116
}
117