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.
Failure conditions met
Pushbf7046...18e86d
passed — Build
created

Svn::check()   A

↳ Parent: Svn

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <ehtnam6@gmail.com>
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
13
namespace Rocketeer\Binaries\Vcs;
14
15
use Rocketeer\Binaries\AbstractBinary;
16
17
/**
18
 * The Svn implementation of the VcsInterface.
19
 *
20
 *
21
 * @author Gasillo
22
 */
23
class Svn extends AbstractBinary implements VcsInterface
24
{
25
    /**
26
     * The core binary.
27
     *
28
     * @var string
29
     */
30
    public $binary = 'svn';
31
32
    ////////////////////////////////////////////////////////////////////
33
    ///////////////////////////// INFORMATIONS /////////////////////////
34
    ////////////////////////////////////////////////////////////////////
35
36
    /**
37
     * Check if the VCS is available.
38
     *
39
     * @return string
40
     */
41 1
    public function check()
42
    {
43 1
        return $this->getCommand('--version');
44
    }
45
46
    /**
47
     * Get the current state.
48
     *
49
     * @return string
50
     */
51 1
    public function currentState()
52
    {
53 1
        return $this->getCommand('info | grep "Revision"');
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function currentEndpoint()
60
    {
61
        return $this->getCommand("info | grep '^URL' | awk '{print \$NF}'");
62
    }
63
64
    /**
65
     * Get the current branch.
66
     *
67
     * @return string
68
     */
69 1
    public function currentBranch()
70
    {
71 1
        return 'echo trunk';
72
    }
73
74
    ////////////////////////////////////////////////////////////////////
75
    /////////////////////////////// ACTIONS ////////////////////////////
76
    ////////////////////////////////////////////////////////////////////
77
78
    /**
79
     * Clone a repository.
80
     *
81
     * @param string $destination
82
     *
83
     * @return string
84
     */
85 5
    public function checkout($destination)
86
    {
87 5
        $repository = $this->credentials->getCurrentRepository();
88 5
        $branch = $repository->branch;
89 5
        $repository = $repository->repository;
90 5
        $repository = rtrim($repository, '/').'/'.ltrim($branch, '/');
91 5
        $repository = preg_replace('#//[a-zA-Z0-9.]+:?[a-zA-Z0-9]*@#', '//', $repository);
92
93 5
        return $this->co([$repository, $destination], $this->getCredentials());
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method co does not exist on object<Rocketeer\Binaries\Vcs\Svn>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
94
    }
95
96
    /**
97
     * Resets the repository.
98
     *
99
     * @return string
100
     */
101 1
    public function reset()
102
    {
103 1
        $command = sprintf('status -q | grep -v \'^[~XI ]\' | awk \'{print $2;}\' | xargs --no-run-if-empty %s revert', $this->binary);
104
105 1
        return $this->getCommand($command);
106
    }
107
108
    /**
109
     * Updates the repository.
110
     *
111
     * @return string
112
     */
113 1
    public function update()
114
    {
115 1
        return $this->up([], $this->getCredentials());
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method up does not exist on object<Rocketeer\Binaries\Vcs\Svn>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
116
    }
117
118
    /**
119
     * Return credential options.
120
     *
121
     * @return array|array<string,null>
122
     */
123 6
    protected function getCredentials()
124
    {
125 6
        $options = ['--non-interactive' => null];
126 6
        $repository = $this->credentials->getCurrentRepository();
127
128
        // Build command
129 6
        if ($user = $repository->username) {
130 4
            $options['--username'] = $user;
131 4
        }
132 6
        if ($pass = $repository->password) {
133 4
            $options['--password'] = $pass;
134 4
        }
135
136 6
        return $options;
137
    }
138
139
    /**
140
     * Checkout the repository's submodules.
141
     *
142
     * @return string|null
143
     */
144 2
    public function submodules()
145
    {
146 2
    }
147
}
148