Completed
Push — master ( afce1d...f8221d )
by Vladimir
09:37
created

MakeIntent   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Console;
6
7
use Illuminate\Console\Command;
8
use FondBot\Conversation\ConversationCreator;
9
10 View Code Duplication
class MakeIntent extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
11
{
12
    protected $signature = 'make:intent
13
                            {name : Name of intent}';
14
15
    protected $description = 'Create a new intent class';
16
17
    public function handle(ConversationCreator $creator): void
18
    {
19
        $name = $this->argument('name');
20
21
        $creator->createIntent('src', 'Bot', $name);
0 ignored issues
show
Bug introduced by
It seems like $name defined by $this->argument('name') on line 19 can also be of type array; however, FondBot\Conversation\Con...Creator::createIntent() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
22
23
        $this->info('Intent created.');
24
    }
25
}
26