Passed
Push — master ( 9de3df...49c81a )
by Richard
11:22 queued 11s
created

PublishTemplateCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
eloc 21
dl 0
loc 88
rs 10
c 3
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A publishSwaggerTemplates() 0 5 1
A publishScaffoldTemplates() 0 7 1
A getArguments() 0 3 1
A publishGeneratorTemplates() 0 9 1
A getOptions() 0 3 1
A handle() 0 10 2
1
<?php
2
3
namespace PWWEB\Artomator\Commands\Publish;
4
5
use InfyOm\Generator\Commands\Publish\PublishBaseCommand;
6
7
class PublishTemplateCommand extends PublishBaseCommand
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'artomator.publish:templates';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Publishes artomator generator templates.';
22
23
    private $templatesDir;
24
25
    /**
26
     * Execute the command.
27
     */
28
    public function handle()
29
    {
30
        $this->templatesDir = config(
31
            'infyom.laravel_generator.path.templates_dir',
32
            resource_path('infyom/infyom-generator-templates/')
33
        );
34
35
        if ($this->publishGeneratorTemplates()) {
36
            $this->publishScaffoldTemplates();
37
            $this->publishSwaggerTemplates();
38
        }
39
    }
40
41
    /**
42
     * Publishes templates.
43
     */
44
    public function publishGeneratorTemplates()
45
    {
46
        $templatesPath = __DIR__.'/../../../../../infyomlabs/laravel-generator/templates';
47
48
        $this->publishDirectory($templatesPath, $this->templatesDir, 'infyom-generator-templates');
49
50
        $templatesPath = __DIR__.'/../../../templates';
51
52
        return $this->publishDirectory($templatesPath, $this->templatesDir, 'pwweb-artomator-templates');
53
    }
54
55
    /**
56
     * Publishes scaffold stemplates.
57
     */
58
    public function publishScaffoldTemplates()
59
    {
60
        $templateType = config('infyom.laravel_generator.templates', 'adminlte-templates');
61
62
        $templatesPath = base_path('vendor/infyomlabs/'.$templateType.'/templates/scaffold');
63
64
        return $this->publishDirectory($templatesPath, $this->templatesDir.'scaffold', 'infyom-generator-templates/scaffold', true);
65
    }
66
67
    /**
68
     * Publishes swagger stemplates.
69
     */
70
    public function publishSwaggerTemplates()
71
    {
72
        $templatesPath = base_path('vendor/infyomlabs/swagger-generator/templates');
73
74
        return $this->publishDirectory($templatesPath, $this->templatesDir, 'swagger-generator', true);
75
    }
76
77
    /**
78
     * Get the console command options.
79
     *
80
     * @return array
81
     */
82
    public function getOptions()
83
    {
84
        return [];
85
    }
86
87
    /**
88
     * Get the console command arguments.
89
     *
90
     * @return array
91
     */
92
    protected function getArguments()
93
    {
94
        return [];
95
    }
96
}
97