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

Staged::getFiles()   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 3
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\Hook\Restriction;
16
use CaptainHook\App\Hooks;
17
use SebastianFeldmann\Git\Repository;
18
19
/**
20
 * Trait for all Conditions checking for staged files
21
 *
22
 * Normally we would inject that functionality into the condition but since we want to have individual classes
23
 * that can be referenced in a configuration file, using a Trait is a bit of a workaround.
24
 *
25
 * @package CaptainHook
26
 * @author  Sebastian Feldmann <[email protected]>
27
 * @link    https://github.com/captainhook-git/captainhook
28
 * @since   Class available since Release 5.27.3
29
 */
30
trait Staged
31
{
32
    /**
33
     * Return the hook restriction information
34
     *
35
     * @return \CaptainHook\App\Hook\Restriction
36
     */
37 5
    public static function getRestriction(): Restriction
38
    {
39 5
        return Restriction::fromArray([Hooks::PRE_COMMIT]);
40
    }
41
42
    /**
43
     * @param  \CaptainHook\App\Console\IO       $io
44
     * @param  \SebastianFeldmann\Git\Repository $repository
45
     * @param  array<string>                     $filter
46
     * @return array<string>
47
     */
48 23
    protected function getFiles(IO $io, Repository $repository, array $filter): array
0 ignored issues
show
Unused Code introduced by
The parameter $filter is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
    protected function getFiles(IO $io, Repository $repository, /** @scrutinizer ignore-unused */ array $filter): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $io is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
    protected function getFiles(/** @scrutinizer ignore-unused */ IO $io, Repository $repository, array $filter): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
    {
50 23
        return $repository->getIndexOperator()->getStagedFiles($this->diffFilter);
51
    }
52
}
53