Passed
Push — master ( 11ad65...c28c7e )
by Thomas
04:10 queued 02:14
created

OpenIdeService::openInIde()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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 call()
11
    {
12
        if ($ide = $this->command->option('ide')) {
13
            return $this->openInIde($ide);
14
        }
15
16
        if ($ide = env('APP_EDITOR')) {
17
            return $this->openInIde($ide);
18
        }
19
20
        if ($ide = config('app.editor')) {
21
            return $this->openInIde($ide);
22
        }
23
    }
24
25
    protected function openInIde($ide)
26
    {
27
        if ($ideClass = config('webfactor.generators.ides.' . $ide)) {
28
            (new $ideClass($this->command->filesToBeOpened))->open();
29
30
            return;
31
        }
32
33
        $this->command->error('There is no opener class for ide <comment>' . $ide . '</comment>');
34
    }
35
}
36