Completed
Push — master ( bbdd37...061748 )
by Vincenzo
02:24
created

GeneratorHelperCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 2
getFilePath() 0 1 ?
A getHead() 0 4 1
A getFileName() 0 4 1
A getFileExtension() 0 4 1
A getStub() 0 4 1
1
<?php
2
3
4
namespace App\Lib\Slime\Console;
5
6
7
abstract class GeneratorHelperCommand extends SlimeCommand
8
{
9
    public function run()
10
    {
11
        $result = file_put_contents(
12
            $this->getFilePath() . $this->getFileName() . $this->getFileExtension()
13
            ,
14
            $this->getHead() . $this->getStub()
15
        );
16
        return $result !== false ? 0 : 1;
17
    }
18
19
    protected abstract function getFilePath();
20
21
    protected function getHead()
22
    {
23
        return "<?php" . PHP_EOL;
24
    }
25
26
    protected function getFileName()
27
    {
28
        return $this->getArg(0);
29
    }
30
31
    protected function getFileExtension()
32
    {
33
        return ".php";
34
    }
35
36
    protected function getStub()
37
    {
38
        return "";
39
    }
40
41
}