Passed
Push — main ( 241083...5efb85 )
by Sebastian
04:13
created

Changed::getRestriction()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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\File;
13
14
use CaptainHook\App\Console\IO;
15
use CaptainHook\App\Git;
16
use CaptainHook\App\Hook\Restriction;
17
use CaptainHook\App\Hooks;
18
use SebastianFeldmann\Git\Repository;
19
20
/**
21
 * Trait for all Conditions checking for changed files
22
 *
23
 * Normally we would inject that functionality into the condition but since we want to have individual classes
24
 * that can be referenced in a configuration file, using a Trait is a bit of a workaround.
25
 *
26
 * @package CaptainHook
27
 * @author  Sebastian Feldmann <[email protected]>
28
 * @link    https://github.com/captainhook-git/captainhook
29
 * @since   Class available since Release 5.27.3
30
 */
31
trait Changed
32
{
33
    /**
34
     * @return \CaptainHook\App\Hook\Restriction
35
     */
36 7
    public static function getRestriction(): Restriction
37
    {
38 7
        return Restriction::fromArray([Hooks::PRE_PUSH, Hooks::POST_CHECKOUT, Hooks::POST_MERGE, Hooks::POST_REWRITE]);
39
    }
40
41
    /**
42
     * @param  \CaptainHook\App\Console\IO       $io
43
     * @param  \SebastianFeldmann\Git\Repository $repository
44
     * @param  array<string>                     $diffFilter
45
     * @return array<string>
46
     */
47 27
    protected function getFiles(IO $io, Repository $repository, array $diffFilter): array
48
    {
49 27
        return Git\ChangedFiles::getChangedFiles($io, $repository, $diffFilter);
50
    }
51
}
52