Code Duplication    Length = 63-64 lines in 3 locations

src/Generators/BulkDestroyRequest.php 1 location

@@ 7-69 (lines=63) @@
4
5
use Symfony\Component\Console\Input\InputOption;
6
7
class BulkDestroyRequest extends ClassGenerator {
8
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'jig:generate:request:bulk-destroy';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Generate a Bulk Destroy request class';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function handle()
29
    {
30
        $force = $this->option('force');
31
32
        if ($this->generateClass($force)){
33
            $this->info('Generating '.$this->classFullName.' finished');
34
        }
35
    }
36
37
    protected function buildClass() {
38
39
        return view('jig::bulk-destroy-request', [
40
            'modelBaseName' => $this->modelBaseName,
41
            'modelDotNotation' => $this->modelDotNotation,
42
            'modelWithNamespaceFromDefault' => $this->modelWithNamespaceFromDefault,
43
            'modelVariableName' => $this->modelVariableName,
44
        ])->render();
45
    }
46
47
    protected function getOptions() {
48
        return [
49
            ['model-name', 'm', InputOption::VALUE_OPTIONAL, 'Generates a code for the given model'],
50
            ['force', 'f', InputOption::VALUE_NONE, 'Force will delete files before regenerating request'],
51
        ];
52
    }
53
54
    public function generateClassNameFromTable($tableName) {
55
        return 'BulkDestroy'.$this->modelBaseName;
56
    }
57
58
    /**
59
     * Get the default namespace for the class.
60
     *
61
     * @param string $rootNamespace
62
     * @return string
63
     */
64
    protected function getDefaultNamespace(string $rootNamespace)
65
    {
66
        return $rootNamespace.'\Http\Requests\Admin\\'.$this->modelWithNamespaceFromDefault;
67
    }
68
69
}
70

src/Generators/DestroyRequest.php 1 location

@@ 5-68 (lines=64) @@
2
3
use Symfony\Component\Console\Input\InputOption;
4
5
class DestroyRequest extends ClassGenerator {
6
7
    /**
8
     * The name and signature of the console command.
9
     *
10
     * @var string
11
     */
12
    protected $name = 'jig:generate:request:destroy';
13
14
    /**
15
     * The console command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Generate a Destroy request class';
20
21
    /**
22
     * Execute the console command.
23
     *
24
     * @return void
25
     */
26
    public function handle()
27
    {
28
        $force = $this->option('force');
29
30
        if ($this->generateClass($force)){
31
            $this->info('Generating '.$this->classFullName.' finished');
32
        }
33
    }
34
35
    protected function buildClass() :string {
36
37
        return view('jig::destroy-request', [
38
            'modelBaseName' => $this->modelBaseName,
39
            'modelFullName'                 => $this->modelFullName,
40
            'modelDotNotation' => $this->modelDotNotation,
41
            'modelWithNamespaceFromDefault' => $this->modelWithNamespaceFromDefault,
42
            'modelVariableName' => $this->modelVariableName,
43
        ])->render();
44
    }
45
46
    protected function getOptions() {
47
        return [
48
            ['model-name', 'm', InputOption::VALUE_OPTIONAL, 'Generates a code for the given model'],
49
            ['force', 'f', InputOption::VALUE_NONE, 'Force will delete files before regenerating request'],
50
        ];
51
    }
52
53
    public function generateClassNameFromTable($tableName) :string {
54
        return 'Destroy'.$this->modelBaseName;
55
    }
56
57
    /**
58
     * Get the default namespace for the class.
59
     *
60
     * @param string $rootNamespace
61
     * @return string
62
     */
63
    protected function getDefaultNamespace(string $rootNamespace) :string
64
    {
65
        return $rootNamespace.'\Http\Requests\\'.$this->modelWithNamespaceFromDefault;
66
    }
67
68
}
69

src/Generators/ImpersonalLoginRequest.php 1 location

@@ 5-67 (lines=63) @@
2
3
use Symfony\Component\Console\Input\InputOption;
4
5
class ImpersonalLoginRequest extends ClassGenerator {
6
7
    /**
8
     * The name and signature of the console command.
9
     *
10
     * @var string
11
     */
12
    protected $name = 'jig:generate:request:impersonal-login';
13
14
    /**
15
     * The console command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Generate a Impersonal login request class';
20
21
    /**
22
     * Execute the console command.
23
     *
24
     * @return mixed
25
     */
26
    public function handle()
27
    {
28
        $force = $this->option('force');
29
30
        if ($this->generateClass($force)){
31
            $this->info('Generating '.$this->classFullName.' finished');
32
        }
33
    }
34
35
    protected function buildClass() {
36
37
        return view('jig::templates.admin-user.impersonal-login-request', [
38
            'modelBaseName' => $this->modelBaseName,
39
            'modelDotNotation' => $this->modelDotNotation,
40
            'modelWithNamespaceFromDefault' => $this->modelWithNamespaceFromDefault,
41
            'modelVariableName' => $this->modelVariableName,
42
        ])->render();
43
    }
44
45
    protected function getOptions() {
46
        return [
47
            ['model-name', 'm', InputOption::VALUE_OPTIONAL, 'Generates a code for the given model'],
48
            ['force', 'f', InputOption::VALUE_NONE, 'Force will delete files before regenerating request'],
49
        ];
50
    }
51
52
    public function generateClassNameFromTable($tableName) {
53
        return 'ImpersonalLogin'.$this->modelBaseName;
54
    }
55
56
    /**
57
     * Get the default namespace for the class.
58
     *
59
     * @param string $rootNamespace
60
     * @return string
61
     */
62
    protected function getDefaultNamespace(string $rootNamespace)
63
    {
64
        return $rootNamespace.'\Http\Requests\Admin\\'.$this->modelWithNamespaceFromDefault;
65
    }
66
67
}
68