PostRewrite   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 8
cp 0.875
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getChangedFiles() 0 12 3
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\Range\Detector\PostRewrite as RangeDetector;
16
use CaptainHook\App\Git\Rev\Util;
17
18
/**
19
 * Class PostRewrite
20
 *
21
 * @package CaptainHook
22
 * @author  Sebastian Feldmann <[email protected]>
23
 * @link    https://github.com/captainhook-git/captainhook
24
 * @since   Class available since Release 5.20.0
25
 */
26
class PostRewrite extends Detector
27
{
28
    /**
29
     * Returns a list of changed files
30
     *
31
     * @param  array<string> $filter
32
     * @return array<string>
33
     */
34 1
    public function getChangedFiles(array $filter = []): array
35
    {
36 1
        $detector = new RangeDetector();
37 1
        $ranges   = $detector->getRanges($this->io);
38 1
        $old      = $ranges[0]->from()->id();
39 1
        $new      = $ranges[0]->to()->id();
40
41 1
        if (Util::isZeroHash($old) || Util::isZeroHash($new)) {
42
            return [];
43
        }
44
45 1
        return $this->repository->getDiffOperator()->getChangedFiles($old, $new, $filter);
46
    }
47
}
48