CustomValueIsFalsy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 29
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isTrue() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Hook\Condition\Config;
13
14
use CaptainHook\App\Console\IO;
15
use CaptainHook\App\Hook\Condition;
16
use CaptainHook\App\Hooks;
17
use SebastianFeldmann\Git\Repository;
18
19
/**
20
 * Class CustomValueIsFalsy
21
 *
22
 * Example configuration:
23
 *
24
 * "action": "some-action"
25
 * "conditions": [
26
 *   {"exec": "\\CaptainHook\\App\\Hook\\Condition\\Config\\CustomValueIsFalsy",
27
 *    "args": [
28
 *      "NAME_OF_CUSTOM_VALUE"
29
 *    ]}
30
 * ]
31
 *
32
 * @package CaptainHook
33
 * @author  Sebastian Feldmann <[email protected]>
34
 * @link    https://github.com/captainhook-git/captainhook
35
 * @since   Class available since Release 5.17.2
36
 */
37
class CustomValueIsFalsy extends Condition\Config
38
{
39
    /**
40
     * Custom config value to check
41
     *
42
     * @var string
43
     */
44
    private string $value;
45
46
    /**
47
     * CustomValueIsFalsy constructor
48
     *
49
     * @param string $value
50
     */
51 2
    public function __construct(string $value)
52
    {
53 2
        $this->value = $value;
54
    }
55
56
    /**
57
     * Evaluates the condition
58
     *
59
     * @param  \CaptainHook\App\Console\IO       $io
60
     * @param  \SebastianFeldmann\Git\Repository $repository
61
     * @return bool
62
     */
63 2
    public function isTrue(IO $io, Repository $repository): bool
64
    {
65 2
        return !$this->checkCustomValue($this->value, false);
66
    }
67
}
68