MakeHookCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 13
c 3
b 0
f 0
dl 0
loc 28
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 11 2
1
<?php
2
3
namespace CleaniqueCoders\Console\Hook;
4
5
use CleaniqueCoders\Console\Commander;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class MakeHookCommand extends Commander
12
{
13
    /**
14
     * Configure the command options.
15
     */
16
    protected function configure()
17
    {
18
        $this
19
            ->setName('hook')
20
            ->setDescription('Hook package to a Laravel project locally')
21
            ->addArgument('name', InputArgument::REQUIRED)
22
            ->addArgument('to', InputArgument::REQUIRED);
23
    }
24
25
    /**
26
     * Execute the command.
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $name      = $input->getArgument('name');
31
        $pathOrUrl = $input->getArgument('to');
32
33
        $status = $this->composerLink(Str::snake($name), $pathOrUrl);
0 ignored issues
show
Bug introduced by
It seems like $name can also be of type string[]; however, parameter $value of Illuminate\Support\Str::snake() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

33
        $status = $this->composerLink(Str::snake(/** @scrutinizer ignore-type */ $name), $pathOrUrl);
Loading history...
Bug introduced by
It seems like $pathOrUrl can also be of type string[]; however, parameter $pathOrUrl of CleaniqueCoders\Console\Commander::composerLink() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

33
        $status = $this->composerLink(Str::snake($name), /** @scrutinizer ignore-type */ $pathOrUrl);
Loading history...
34
35
        if ($status) {
0 ignored issues
show
introduced by
The condition $status is always true.
Loading history...
36
            $output->writeln('<info>Packaged linked.</info>');
37
        } else {
38
            $output->writeln('<comment>Unable to link the package.</comment>');
39
        }
40
    }
41
}
42