Completed
Push — master ( 92becb...f2a5b4 )
by Matthias
02:20
created

Jenkins::getAuthor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace MatthiasMullie\CI\Providers;
4
5
use MatthiasMullie\CI\Environment;
6
7
/**
8
 * @see https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables
9
 * @see https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables
10
 *
11
 * @author Matthias Mullie <[email protected]>
12
 * @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved.
13
 * @license LICENSE MIT
14
 */
15
class Jenkins extends None implements Environment
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public static function isCurrent()
21
    {
22
        return getenv('JENKINS_URL') !== false;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getProvider()
29
    {
30
        return 'jenkins';
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getRepo()
37
    {
38
        return getenv('GIT_URL');
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getBranch()
45
    {
46
        return getenv('ghprbSourceBranch') ?: getenv('GIT_BRANCH') ?: getenv('CVS_BRANCH');
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getPullRequest()
53
    {
54
        return getenv('ghprbPullId') ?: '';
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getCommit()
61
    {
62
        return getenv('ghprbActualCommit') ?: getenv('GIT_COMMIT');
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getAuthor()
69
    {
70
        return getenv('ghprbActualCommitAuthor') ?: parent::getAuthor();
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getAuthorEmail()
77
    {
78
        return getenv('ghprbActualCommitAuthorEmail') ?: parent::getAuthor();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getAuthor() instead of getAuthorEmail()). Are you sure this is correct? If so, you might want to change this to $this->getAuthor().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getBuild()
85
    {
86
        return getenv('BUILD_NUMBER');
87
    }
88
}
89