Passed
Push — main ( e2c1fb...af4d5c )
by Sebastian
03:52
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\Git\Rev\Util;
16
use CaptainHook\App\Hooks;
17
18
/**
19
 * Class Fallback
20
 *
21
 * This class should not be used it is just a fallback if the `pre-push` or `post-rewrite`
22
 * variants are somehow not applicable.
23
 *
24
 * @package CaptainHook
25
 * @author  Sebastian Feldmann <[email protected]>
26
 * @link    https://github.com/captainhook-git/captainhook
27
 * @since   Class available since Release 5.20.0
28
 */
29
class Fallback extends Detector
30
{
31
    /**
32
     * Returns the list of changed files in a best-guess kind of way
33
     *
34
     * @param  array<string> $filter
35
     * @return array<string>
36
     */
37 26
    public function getChangedFiles(array $filter = []): array
38
    {
39 26
        return $this->repository->getDiffOperator()->getChangedFiles(
40 26
            $this->io->getArgument(Hooks::ARG_PREVIOUS_HEAD, 'HEAD@{1}'),
41 26
            'HEAD',
42 26
            $filter
43 26
        );
44
    }
45
}
46