Code Duplication    Length = 77-80 lines in 10 locations

sources/Generators/Console/EventMakeCommand.php 1 location

@@ 10-87 (lines=78) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class EventMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:event
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new event class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Event';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\Events';
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'event.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'root_namespace' => $this->getAppNamespace(),     // use App\Events\Event
84
            'class' => $class,
85
        ]);
86
    }
87
}
88

sources/Generators/Console/JobMakeCommand.php 1 location

@@ 10-88 (lines=79) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class JobMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:job
20
        {name : The name of the class}
21
        {--addon= : The name of the addon}
22
        {--sync : Indicates that job should be synchronous}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new job class';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Job';
38
39
    /**
40
     * The constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
46
        $this->setStubDirectory(__DIR__.'/../stubs');
47
    }
48
49
    /**
50
     * Get the default namespace for the class.
51
     *
52
     * @return string
53
     */
54
    protected function getDefaultNamespace()
55
    {
56
        return $this->getRootNamespace().'\\Jobs';
57
    }
58
59
    /**
60
     * Get the stub file for the generator.
61
     *
62
     * @return string
63
     */
64
    protected function getStub()
65
    {
66
        return $this->option('sync') ? 'job-sync.stub' : 'job-queued.stub';
67
    }
68
69
    /**
70
     * Generate file.
71
     *
72
     * @param \Jumilla\Generators\FileGenerator $generator
73
     * @param string $path
74
     * @param string $fqcn
75
     *
76
     * @return bool
77
     */
78
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
79
    {
80
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
81
82
        return $generator->file($path)->template($this->getStub(), [
83
            'namespace' => $namespace,
84
            'root_namespace' => $this->getAppNamespace(),     // use App\Jobs\Job
85
            'class' => $class,
86
        ]);
87
    }
88
}
89

sources/Generators/Console/ProviderMakeCommand.php 1 location

@@ 10-86 (lines=77) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class ProviderMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:provider
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new service provider class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Provider';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\Providers';
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'provider.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'class' => $class,
84
        ]);
85
    }
86
}
87

sources/Generators/Console/CommandMakeCommand.php 1 location

@@ 10-88 (lines=79) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class CommandMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:console
20
        {name : The name of the class}
21
        {--addon= : The name of the addon}
22
        {--command=command.name : The terminal command that should be assigned}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new Artisan command';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Console';
38
39
    /**
40
     * The constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
46
        $this->setStubDirectory(__DIR__.'/../stubs');
47
    }
48
49
    /**
50
     * Get the default namespace for the class.
51
     *
52
     * @return string
53
     */
54
    protected function getDefaultNamespace()
55
    {
56
        return $this->getRootNamespace().'\\'.($this->onAddon() ? 'Commands' : 'Console\\Commands');
57
    }
58
59
    /**
60
     * Get the stub file for the generator.
61
     *
62
     * @return string
63
     */
64
    protected function getStub()
65
    {
66
        return 'command.stub';
67
    }
68
69
    /**
70
     * Generate file.
71
     *
72
     * @param \Jumilla\Generators\FileGenerator $generator
73
     * @param string $path
74
     * @param string $fqcn
75
     *
76
     * @return bool
77
     */
78
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
79
    {
80
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
81
82
        return $generator->file($path)->template($this->getStub(), [
83
            'namespace' => $namespace,
84
            'class' => $class,
85
            'command' => $this->option('command'),
86
        ]);
87
    }
88
}
89

sources/Generators/Console/ControllerMakeCommand.php 1 location

@@ 10-88 (lines=79) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class ControllerMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:controller
20
        {name : The name of the class}
21
        {--addon= : The name of the addon}
22
        {--resource : Generate a resource controller class}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new controller class';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Controller';
38
39
    /**
40
     * The constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
46
        $this->setStubDirectory(__DIR__.'/../stubs');
47
    }
48
49
    /**
50
     * Get the default namespace for the class.
51
     *
52
     * @return string
53
     */
54
    protected function getDefaultNamespace()
55
    {
56
        return $this->getRootNamespace().'\\'.($this->onAddon() ? 'Controllers' : 'Http\\Controllers');
57
    }
58
59
    /**
60
     * Get the stub file for the generator.
61
     *
62
     * @return string
63
     */
64
    protected function getStub()
65
    {
66
        return $this->option('resource') ? 'controller-resource.stub' : 'controller.stub';
67
    }
68
69
    /**
70
     * Generate file.
71
     *
72
     * @param \Jumilla\Generators\FileGenerator $generator
73
     * @param string $path
74
     * @param string $fqcn
75
     *
76
     * @return bool
77
     */
78
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
79
    {
80
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
81
82
        return $generator->file($path)->template($this->getStub(), [
83
            'namespace' => $namespace,
84
            'root_namespace' => $this->getAppNamespace(),   // use App\Http\Controllers\Controller
85
            'class' => $class,
86
        ]);
87
    }
88
}
89

sources/Generators/Console/MailMakeCommand.php 1 location

@@ 10-86 (lines=77) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class MailMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:event
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new email class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Mail';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\Mail';
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'mail.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'class' => $class,
84
        ]);
85
    }
86
}
87

sources/Generators/Console/MiddlewareMakeCommand.php 1 location

@@ 10-86 (lines=77) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class MiddlewareMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:middleware
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new middleware class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Middleware';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\'.($this->onAddon() ? 'Middleware' : 'Http\\Middleware');
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'middleware.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'class' => $class,
84
        ]);
85
    }
86
}
87

sources/Generators/Console/NotificationMakeCommand.php 1 location

@@ 10-86 (lines=77) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class NotificationMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:event
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new email class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Notification';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\Notifications';
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'notification.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'class' => $class,
84
        ]);
85
    }
86
}
87

sources/Generators/Console/PolicyMakeCommand.php 1 location

@@ 10-89 (lines=80) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class PolicyMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:policy
20
        {name : The name of the class}
21
        {--m|model : The model that the policy applies to}
22
        {--a|addon= : The name of the addon}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new policy class';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Policy';
38
39
    /**
40
     * The constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
46
        $this->setStubDirectory(__DIR__.'/../stubs');
47
    }
48
49
    /**
50
     * Get the default namespace for the class.
51
     *
52
     * @return string
53
     */
54
    protected function getDefaultNamespace()
55
    {
56
        return $this->getRootNamespace().'\\Policies';
57
    }
58
59
    /**
60
     * Get the stub file for the generator.
61
     *
62
     * @return string
63
     */
64
    protected function getStub()
65
    {
66
        return $this->option('model') ? 'policy-model.stub' : 'policy.stub';
67
    }
68
69
    /**
70
     * Generate file.
71
     *
72
     * @param FileGenerator $generator
73
     * @param string        $path
74
     * @param string        $fqcn
75
     *
76
     * @return bool
77
     */
78
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
79
    {
80
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
81
82
        return $generator->file($path)->template($this->getStub(), [
83
            'namespace' => $namespace,
84
            'class' => $class,
85
            'root_namespace' => $this->getAppNamespace(),     // use App\Jobs\Job
86
            'model' => $this->option('model'),
87
        ]);
88
    }
89
}
90

sources/Generators/Console/RequestMakeCommand.php 1 location

@@ 10-87 (lines=78) @@
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10
class RequestMakeCommand extends BaseCommand
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:request
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new form request class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Request';
37
38
    /**
39
     * The constructor.
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
45
        $this->setStubDirectory(__DIR__.'/../stubs');
46
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53
    protected function getDefaultNamespace()
54
    {
55
        return $this->getRootNamespace().'\\'.($this->onAddon() ? 'Requests' : 'Http\\Requests');
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63
    protected function getStub()
64
    {
65
        return 'request.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81
        return $generator->file($path)->template($this->getStub(), [
82
            'namespace' => $namespace,
83
            'root_namespace' => $this->getAppNamespace(),       // use App\Http\Requests\Request
84
            'class' => $class,
85
        ]);
86
    }
87
}
88