NotOnMatching   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
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
declare(strict_types=1);
13
14
namespace CaptainHook\App\Hook\Condition\Branch;
15
16
use CaptainHook\App\Console\IO;
17
use SebastianFeldmann\Git\Repository;
18
19
/**
20
 * NotOnMatching Branch condition
21
 *
22
 * Example configuration:
23
 * <code>
24
 * {
25
 *   "action": "some-action",
26
 *   "conditions": [
27
 *     {
28
 *       "exec": "CaptainHook.Status.NotOnMatchingBranch",
29
 *       "args": ["#^branches-names/not-matching[0-9]+-this-regex$#i"]
30
 *     }
31
 *   ]
32
 * }
33
 * </code>
34
 *
35
 * @package CaptainHook
36
 * @author  Sebastian Feldmann <[email protected]>
37
 * @link    https://github.com/captainhook-git/captainhook
38
 * @since   Class available since Release 5.20.2
39
 */
40
class NotOnMatching extends Name
41
{
42
    /**
43
     * Check if the current branch is matched by the configured regex
44
     *
45
     * @param  \CaptainHook\App\Console\IO       $io
46
     * @param  \SebastianFeldmann\Git\Repository $repository
47
     * @return bool
48
     */
49 2
    public function isTrue(IO $io, Repository $repository): bool
50
    {
51 2
        return preg_match($this->name, trim($repository->getInfoOperator()->getCurrentBranch())) === 0;
52
    }
53
}
54