GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Git::committedFiles()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/*
4
 * This file is part of the CS library.
5
 *
6
 * Copyright (c) 2015-present LIN3S <[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
declare(strict_types=1);
13
14
namespace LIN3S\CS\Git;
15
16
use Symfony\Component\Process\Process;
17
18
/**
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
final class Git
22
{
23
    public static function committedFiles()
24
    {
25
        $output = [];
26
        $rc = 0;
27
28
        exec('git rev-parse --verify HEAD 2> /dev/null', $output, $rc);
29
30
        $against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
31
        if (0 === $rc) {
32
            $against = 'HEAD';
33
        }
34
35
        exec("git diff-index --cached --name-status $against | egrep '^(A|M)' | awk '{print $2;}'", $output);
36
37
        return $output;
38
    }
39
40
    public static function addFiles(array $files, $rootDirectory = null)
41
    {
42
        foreach ($files as $file) {
43
            if (false === file_exists($file)) {
44
                continue;
45
            }
46
            $process = new Process(sprintf('git add %s', $file), $rootDirectory);
47
            $process->run();
48
        }
49
50
        return $files;
51
    }
52
}
53