Completed
Push — master ( e8cd9a...d9ab14 )
by Sebastian
05:17
created

Guided   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isPHPActionOptionValid() 0 7 2
1
<?php
2
/**
3
 * This file is part of CaptainHook.
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
namespace SebastianFeldmann\CaptainHook\Runner\Configurator\Setup;
11
12
use SebastianFeldmann\CaptainHook\Config;
13
use SebastianFeldmann\CaptainHook\Console\IO;
14
use SebastianFeldmann\CaptainHook\Console\IOUtil;
15
use SebastianFeldmann\CaptainHook\Hook\Util;
16
use SebastianFeldmann\CaptainHook\Runner\Configurator\Setup;
17
18
/**
19
 * Class Guided
20
 *
21
 * @package CaptainHook
22
 * @author  Sebastian Feldmann <[email protected]>
23
 * @link    https://github.com/sebastianfeldmann/captainhook
24
 * @since   Class available since Release 2.2.0
25
 */
26
abstract class Guided
27
{
28
    /**
29
     * @var \SebastianFeldmann\CaptainHook\Console\IO
30
     */
31
    protected $io;
32
33
    /**
34
     * Guided constructor.
35
     *
36
     * @param \SebastianFeldmann\CaptainHook\Console\IO $io
37
     */
38 6
    public function __construct(IO $io)
39
    {
40 6
        $this->io = $io;
41 6
    }
42
43
    /**
44
     * PHP action option validation
45
     *
46
     * @param  string $option
47
     * @return string
48
     * @throws \Exception
49
     */
50 2
    public static function isPHPActionOptionValid(string $option): string
51
    {
52 2
        if (count(explode(':', $option)) !== 2) {
53 1
            throw new \Exception('Invalid option, use "key:value"');
54
        }
55 1
        return $option;
56
    }
57
}
58