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

PostRewrite::getChangedFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
ccs 6
cts 6
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\Git\Range\Detector\PostRewrite as RangeDetector;
16
17
/**
18
 * Class PostRewrite
19
 *
20
 * @package CaptainHook
21
 * @author  Sebastian Feldmann <[email protected]>
22
 * @link    https://github.com/captainhookphp/captainhook
23
 * @since   Class available since Release 5.20.0
24
 */
25
class PostRewrite extends Detector
26
{
27
    /**
28
     * Returns a list of changed files
29
     *
30
     * @param  array<string> $filter
31
     * @return array<string>
32
     */
33 1
    public function getChangedFiles(array $filter = []): array
34
    {
35 1
        $detector = new RangeDetector();
36 1
        $ranges   = $detector->getRanges($this->io);
37 1
        $old      = $ranges[0]->from()->id();
38 1
        $new      = $ranges[0]->to()->id();
39
40 1
        return $this->repository->getDiffOperator()->getChangedFiles($old, $new, $filter);
41
    }
42
}
43