Passed
Push — main ( 604bfc...f70419 )
by Sebastian
04:51
created

Fallback::getChangedFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
ccs 5
cts 5
cp 1
crap 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\Git\ChangedFiles\Detector;
13
14
use CaptainHook\App\Git\ChangedFiles\Detector;
15
use CaptainHook\App\Hooks;
16
17
/**
18
 * Class Fallback
19
 *
20
 * This class should not be used it is just a fallback if the `pre-push` or `post-rewrite`
21
 * variants are somehow not applicable.
22
 *
23
 * @package CaptainHook
24
 * @author  Sebastian Feldmann <[email protected]>
25
 * @link    https://github.com/captainhookphp/captainhook
26
 * @since   Class available since Release 5.20.0
27
 */
28
class Fallback extends Detector
29
{
30
    /**
31
     * Returns the list of changed files in a best-guess kind of way
32
     *
33
     * @param  array<string> $filter
34
     * @return array<string>
35
     */
36 15
    public function getChangedFiles(array $filter = []): array
37
    {
38 15
        return $this->repository->getDiffOperator()->getChangedFiles(
39 15
            $this->io->getArgument(Hooks::ARG_PREVIOUS_HEAD, 'HEAD@{1}'),
40 15
            'HEAD',
41 15
            $filter
42 15
        );
43
    }
44
}
45