Completed
Push — master ( ca4c8c...687844 )
by Sebastian
03:10
created

Util::getExecType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Git.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace CaptainHook\App\Runner;
12
13
/**
14
 * Class Util
15
 *
16
 * @package CaptainHook\App\Runner
17
 */
18
final class Util
19
{
20
    /**
21
     * List of valid action types
22
     *
23
     * @var array
24
     */
25
    private static $validTypes = ['php' => true, 'cli' => true];
26
27
28
    /**
29
     * Check the validity of a exec type
30
     *
31
     * @param  string $type
32
     * @return bool
33
     */
34 1
    public static function isTypeValid(string $type) : bool
35
    {
36 1
        return isset(self::$validTypes[$type]);
37
    }
38
39
    /**
40
     * Return action type
41
     *
42
     * @param  string $action
43
     * @return string
44
     */
45 18
    public static function getExecType(string $action) : string
46
    {
47 18
        return substr($action, 0, 1) === '\\' ? 'php' : 'cli';
48
    }
49
}
50