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

Cli   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 38
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 isTrue() 0 5 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\Hook\Condition;
11
12
use CaptainHook\App\Config;
13
use CaptainHook\App\Console\IO;
14
use CaptainHook\App\Hook\Condition;
15
use SebastianFeldmann\Cli\Processor;
16
use SebastianFeldmann\Git\Repository;
17
18
/**
19
 * Class Cli
20
 *
21
 * @package CaptainHook
22
 * @author  Sebastian Feldmann <[email protected]>
23
 * @link    https://github.com/captainhookphp/captainhook
24
 * @since   Class available since Release 4.2.0
25
 */
26
class Cli implements Condition
27
{
28
    /**
29
     * Binary executor
30
     *
31
     * @var \SebastianFeldmann\Cli\Processor
32
     */
33
    private $processor;
34
35
    /**
36
     * @var string
37
     */
38
    private $command;
39
40
    /**
41
     * Cli constructor.
42
     *
43
     * @param \SebastianFeldmann\Cli\Processor $processor
44
     * @param string                           $command
45
     */
46 3
    public function __construct(Processor $processor, string $command)
47
    {
48 3
        $this->processor = $processor;
49 3
        $this->command   = $command;
50 3
    }
51
52
    /**
53
     * Evaluates a condition
54
     *
55
     * @param  \CaptainHook\App\Console\IO       $io
56
     * @param  \SebastianFeldmann\Git\Repository $repository
57
     * @return bool
58
     */
59 3
    public function isTrue(IO $io, Repository $repository) : bool
60
    {
61 3
        $result = $this->processor->run($this->command);
62
63 3
        return $result->isSuccessful();
64
    }
65
}
66