Passed
Push — master ( 7bee4d...457c92 )
by Sebastian
01:54
created

Guided::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

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