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

OpenIdeService   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 28
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A call() 0 14 4
A openInIde() 0 10 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 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