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

Fallback   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getChangedFiles() 0 6 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