Code Duplication    Length = 77-79 lines in 7 locations

sources/Generators/Commands/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/Commands/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
        {--a|addon= : The name of the addon}
22
        {--s|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/Commands/MailMakeCommand.php 1 location

@@ 10-87 (lines=78) @@
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:mail
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
        {--m|markdown : Create a new Markdown template for the mailable}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new email class';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Mail';
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().'\\Mail';
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('markdown') ? 'mail-markdown.stub' : 'mail-view.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
        ]);
86
    }
87
}
88

sources/Generators/Commands/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/Commands/NotificationMakeCommand.php 1 location

@@ 10-87 (lines=78) @@
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:notification
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
        {--m|markdown : Create a new Markdown template for the notification}
23
    ';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = '[+] Create a new email class';
31
32
    /**
33
     * The type of class being generated.
34
     *
35
     * @var string
36
     */
37
    protected $type = 'Notification';
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().'\\Notifications';
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('markdown') ? 'notification-markdown.stub' : 'notification-html.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
        ]);
86
    }
87
}
88

sources/Generators/Commands/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/Commands/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