FilterMakeCommand::getStub()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace HChamran\LaravelFilter\Commands;
4
5
use Illuminate\Support\Str;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Str was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Console\GeneratorCommand;
0 ignored issues
show
Bug introduced by
The type Illuminate\Console\GeneratorCommand was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Symfony\Component\Console\Input\InputArgument;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputArgument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Console\Exception\InvalidArgumentException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Consol...nvalidArgumentException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class FilterMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'make:filter {name}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new filter class';
25
26
    /**
27
     * The type of class being generated.
28
     *
29
     * @var string
30
     */
31
    protected $type = 'Filter';
32
33
    /**
34
     * Execute the console command.
35
     *
36
     * @return mixed
37
     */
38
    public function handle()
39
    {
40
        parent::handle();
41
    }
42
43
    /**
44
     * Get the default namespace for the class.
45
     *
46
     * @param  string  $rootNamespace
47
     * @return string
48
     */
49
    protected function getDefaultNamespace($rootNamespace)
50
    {
51
        return $rootNamespace . '\Filters';
52
    }
53
54
    /**
55
     * Get the stub file for the generator.
56
     *
57
     * @return string
58
     */
59
    protected function getStub()
60
    {
61
        return __DIR__ . '/../../stubs/filter.stub';
62
    }
63
64
    /**
65
     * Get the console command arguments.
66
     *
67
     * @return array
68
     */
69
    protected function getArguments()
70
    {
71
        return [
72
            ['name', InputArgument::REQUIRED, 'The name of the model class.'],
73
        ];
74
    }
75
76
    /**
77
     * Replace the class name for the given stub.
78
     *
79
     * @param  string  $stub
80
     * @param  string  $name
81
     * @return string
82
     */
83
    protected function replaceClass($stub, $name)
84
    {
85
        $class = str_replace($this->getNamespace($name).'\\', '', $name);
86
87
        return str_replace('DummyFilter', $class, $stub);
88
    }
89
90
    protected function replaceNamespace(&$stub, $name)
91
    {
92
        $stub = str_replace('DummyNamespace', $this->getNamespace($name), $stub);
93
94
        return $this;
95
    }
96
}
97