Passed
Pull Request — master (#36)
by Cristian
02:10
created

ServiceAbstract::getConsoleOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Contracts;
4
5
use Illuminate\Filesystem\Filesystem;
6
7
abstract class ServiceAbstract
8
{
9
    protected $command;
10
11
    protected $key;
12
13
    protected $naming;
14
15
    protected $filesystem;
16
17
    public function __construct(CommandAbstract $command, ?NamingAbstract $naming = null)
18
    {
19
        $this->command = $command;
20
        $this->filesystem = new Filesystem();
21
22
        $this->naming = $naming;
23
24
        if (is_null($naming) && $this->key) {
25
            $this->naming = $this->command->naming[$this->key];
26
        }
27
    }
28
29
    protected function addGeneratedFileToIdeStack()
30
    {
31
        if ($file = $this->command->naming[$this->key]->getFile()) {
32
            $this->command->addFile($this->getSplFile($file));
33
        }
34
    }
35
36
    private function getSplFile(string $pathToFile): \SplFileInfo
37
    {
38
        $splFile = new \SplFileInfo($pathToFile);
39
40
        if ($splFile->isFile()) {
41
            return $splFile;
42
        }
43
44
        return null;
45
    }
46
47
    public function getConsoleOutput() {
48
        return 'Handling ' . $this->key;
49
    }
50
}
51