ChangedFiles   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A replacement() 0 4 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\Runner\Action\Cli\Command\Placeholder;
13
14
use CaptainHook\App\Git;
15
use CaptainHook\App\Hook\FileList;
16
17
/**
18
 * Changed Files Placeholder
19
 *
20
 * This placeholder only works for pre-push, post-rewrite, post-checkout and post-merge actions.
21
 * If it is used in a pre-push hook and multiple refs are pushed the placeholder will contain
22
 * all changed files for all refs.
23
 *
24
 * Usage examples:
25
 *  - {$CHANGED_FILES|separated-by:,}
26
 *  - {$CHANGED_FILES|in-dir:foo/bar}
27
 *  - {$CHANGED_FILES|of-type:php}
28
 *
29
 * @package CaptainHook
30
 * @author  Sebastian Feldmann <[email protected]>
31
 * @link    https://github.com/captainhook-git/captainhook
32
 * @since   Class available since Release 5.15.3
33
 */
34
class ChangedFiles extends Foundation
35
{
36
    /**
37
     * @param  array<string, string> $options
38
     * @return string
39
     */
40 4
    public function replacement(array $options): string
41
    {
42 4
        $files = Git\ChangedFiles::getChangedFiles($this->io, $this->repository, ['A', 'C', 'M', 'R']);
43 4
        return implode(($options['separated-by'] ?? ' '), FileList::filter($files, $options));
44
    }
45
}
46