Passed
Branch develop (1ecfd6)
by Nuno
02:37
created

Command   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 59
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A title() 0 12 1
A setLaravel() 0 3 1
A schedule() 0 2 1
A handle() 0 3 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 LogicException;
17
use function strlen;
18
use function str_repeat;
19
use Illuminate\Console\Scheduling\Schedule;
20
use Illuminate\Console\Command as BaseCommand;
21
22
abstract class Command extends BaseCommand
23
{
24
    /**
25
     * Holds an instance of the app, if any.
26
     *
27
     * @var \Illuminate\Contracts\Foundation\Application|null
28
     */
29
    protected $app;
30
31
    /**
32
     * Execute the console command.
33
     *
34
     * @return void
35
     *
36
     * @throws \LogicException
37
     */
38 1
    public function handle(): void
39
    {
40 1
        throw new LogicException('You must override the handle() method in the concrete command class.');
41
    }
42
43
    /**
44
     * Define the command's schedule.
45
     *
46
     * @param  \Illuminate\Console\Scheduling\Schedule $schedule
47
     *
48
     * @return void
49
     */
50 22
    public function schedule(Schedule $schedule): void
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

50
    public function schedule(/** @scrutinizer ignore-unused */ Schedule $schedule): void

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...
51
    {
52 22
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 22
    public function setLaravel($laravel): void
58
    {
59 22
        parent::setLaravel($this->app = $laravel);
60 22
    }
61
62
    /**
63
     * Displays a title.
64
     *
65
     * @param  string $title
66
     *
67
     * @return \LaravelZero\Framework\Commands\Command
68
     */
69 2
    public function title(string $title): Command
70
    {
71 2
        $size = strlen($title);
72 2
        $spaces = str_repeat(' ', $size);
73
74 2
        $this->output->newLine();
75 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>");
76 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$title$spaces</>");
77 2
        $this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>");
78 2
        $this->output->newLine();
79
80 2
        return $this;
81
    }
82
}
83