Passed
Push — dependabot/npm_and_yarn/docs/w... ( a770a9...3a5b31 )
by
unknown
07:47
created

BlockMake::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace A17\Twill\Commands;
4
5
use A17\Twill\Services\Blocks\BlockMaker;
6
7
class BlockMake extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature =
15
        'twill:make:block ' .
16
        '{name : Name of the new block.} ' .
17
        '{base? : Block on which the new block should be based.}' .
18
        '{icon? : Icon for the new block. List icons using the twill:list:icons command.}';
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new block';
25
26
    /**
27
     * @var \A17\Twill\Services\Blocks\BlockMaker
28
     */
29
    protected $blockMaker;
30
31
    /**
32
     * @param \A17\Twill\Services\Blocks\BlockMaker
33
     */
34 69
    public function __construct(BlockMaker $blockMaker)
35
    {
36 69
        parent::__construct();
37
38 69
        $this->blockMaker = $blockMaker;
39 69
    }
40
41
    /**
42
     * @return \A17\Twill\Services\Blocks\BlockMaker
43
     */
44 5
    public function getBlockMaker(): \A17\Twill\Services\Blocks\BlockMaker
45
    {
46 5
        return $this->blockMaker;
47
    }
48
49
    /**
50
     * Executes the console command.
51
     *
52
     * @return mixed
53
     * @throws \Exception
54
     */
55 5
    public function handle()
56
    {
57 5
        $this->blockMaker
58 5
            ->setCommand($this)
59 5
            ->make(
60 5
                $this->argument('name'),
61 5
                $this->argument('base') ?? 'text',
62 5
                $this->argument('icon') ?? 'text'
63
            );
64
65 5
        return parent::handle();
66
    }
67
}
68