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

Guided::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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