Passed
Push — feature/lg ( 3c06af...b2e7fb )
by Richard
03:07
created

PublishBaseCommand   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 10
eloc 15
c 2
b 0
f 0
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A publishFile() 0 10 3
A handle() 0 2 1
A publishDirectory() 0 13 4
A getArguments() 0 3 1
A getOptions() 0 3 1
1
<?php
2
3
namespace PWWEB\Artomator\Commands\Publish;
4
5
use File;
6
use InfyOm\Generator\Commands\BaseCommand;
7
8
class PublishBaseCommand extends BaseCommand
9
{
10
    public function handle()
11
    {
12
    }
13
14
    public function publishFile($sourceFile, $destinationFile, $fileName)
15
    {
16
        if (file_exists($destinationFile) && ! $this->confirmOverwrite($destinationFile)) {
17
            return;
18
        }
19
20
        copy($sourceFile, $destinationFile);
21
22
        $this->comment($fileName.' published');
23
        $this->info($destinationFile);
24
    }
25
26
    /**
27
     * @param $sourceDir
28
     * @param $destinationDir
29
     * @param $dirName
30
     * @param bool $force
31
     *
32
     * @return bool|void
33
     */
34
    public function publishDirectory($sourceDir, $destinationDir, $dirName, $force = false)
35
    {
36
        if (file_exists($destinationDir) && ! $force && ! $this->confirmOverwrite($destinationDir)) {
37
            return;
38
        }
39
40
        File::makeDirectory($destinationDir, 493, true, true);
41
        File::copyDirectory($sourceDir, $destinationDir);
42
43
        $this->comment($dirName.' published');
44
        $this->info($destinationDir);
45
46
        return true;
47
    }
48
49
    /**
50
     * Get the console command options.
51
     *
52
     * @return array
53
     */
54
    public function getOptions()
55
    {
56
        return [];
57
    }
58
59
    /**
60
     * Get the console command arguments.
61
     *
62
     * @return array
63
     */
64
    protected function getArguments()
65
    {
66
        return [];
67
    }
68
}
69