Passed
Push — master ( aa397c...819f04 )
by Thomas
02:33
created

OpenIdeService::getIde()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
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\Services;
4
5
use Webfactor\Laravel\Generators\Contracts\ServiceAbstract;
6
use Webfactor\Laravel\Generators\Contracts\ServiceInterface;
7
8
class OpenIdeService extends ServiceAbstract implements ServiceInterface
9
{
10
    public function getConsoleOutput()
11
    {
12
        $ide = $this->getIde();
13
14
        return $ide ? 'Opening all generated or edited files in '.$ide : 'Editor not defined - not opening files in IDE';
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
15
    }
16
17
    public function call()
18
    {
19
        if ($this->getIde()) {
20
            return $this->openInIde();
21
        }
22
    }
23
24
    protected function getIde()
25
    {
26
        return $this->command->option('ide') ?? env('APP_EDITOR') ?? config('app.editor') ?? false;
27
    }
28
29
    protected function openInIde()
30
    {
31
        if ($ideClass = config('webfactor.generators.ides.' . $this->getIde())) {
32
            (new $ideClass($this->command->filesToBeOpened))->open();
33
34
            return;
35
        }
36
37
        $this->command->error('There is no opener class for ide <comment>' . $this->getIde() . '</comment>');
38
    }
39
}
40