MakeConsumerCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 17
c 2
b 1
f 1
dl 0
loc 33
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 27 2
1
<?php
2
3
namespace Chocofamily\LaravelEventSauce\Console;
4
5
use Chocofamily\LaravelEventSauce\Exceptions\MakeFileFailed;
6
7
final class MakeConsumerCommand extends MakeCommand
8
{
9
    protected $signature = 'make:consumer {class}';
10
11
    protected $description = 'Create a new consumer class';
12
13
    public function handle(): void
14
    {
15
        /** @var string $class */
16
        $class = $this->argument('class');
17
        /** @scrutinizer ignore-type */
18
        $consumerClass = $this->formatClassName($class);
19
20
        $consumerPath = $this->getPath($consumerClass);
21
        try {
22
            $this->ensureValidPaths([
23
                $consumerPath,
24
            ]);
25
        } catch (MakeFileFailed $exception) {
26
            $this->error($exception->getMessage());
27
        }
28
29
        $this->makeDirectory($consumerPath);
30
31
        $this->makeFiles(
32
            ['Consumer' => $consumerPath],
33
            [
34
                'consumer' => class_basename($consumerClass),
35
                'namespace' => substr($consumerClass, 0, strrpos($consumerClass, '\\')),
36
            ]
37
        );
38
39
        $this->info("{$consumerClass} class created successfully!");
40
    }
41
}
42