Completed
Pull Request — master (#51)
by
unknown
01:45
created

Editor::openWith()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 9

Importance

Changes 0
Metric Value
cc 9
nc 9
nop 1
dl 0
loc 24
ccs 16
cts 16
cp 1
crap 9
rs 8.0555
c 0
b 0
f 0
1
<?php
2
3
namespace Recca0120\LaravelTracy;
4
5
class Editor
6
{
7
    /**
8
     * Editor protocol.
9
     *
10
     * Usage:
11
     *      Editor::openWith('vscode')
12
     *
13
     * https://tracy.nette.org/en/open-files-in-ide
14
     *
15
     * @param string $editor (sublime|subl, phpstorm, vscode, macvim|mvim, textmate|txmt)
16
     * @return string
17
     */
18 8
    public static function openWith($editor = 'subl')
19
    {
20 8
        switch (strtolower($editor)) {
21 8
            case 'phpstorm':
22 1
                return 'phpstorm://open?file=%file&line=%line';
23
24 7
            case 'vscode':
25 2
                return 'vscode://file/%file:%line';
26
27 5
            case 'mvim':
28 5
            case 'macvim':
29 1
                return 'mvim://open/?url=file://%file&line=%line';
30
31 4
            case 'txmt':
32 4
            case 'textmate':
33 1
                return 'txmt://open/?url=file://%file&line=%line';
34
35 3
            case 'subl':
36 2
            case 'sublime':
37 2
                return 'subl://open?url=file://%file&line=%line';
38
        }
39
40 1
        return 'editor://open/?file=%file&line=%line';
41
    }
42
}
43