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.

PingdomSkeleton::postRemove()   B
last analyzed

Complexity

Conditions 7
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 9
nc 4
nop 1
1
<?php
2
namespace Kunstmaan\Skylab\Skeleton;
3
4
/**
5
 * ApacheSkeleton
6
 */
7
class PingdomSkeleton extends AbstractSkeleton
8
{
9
10
    const NAME = "pingdom";
11
12
    /**
13
     * @return string
14
     */
15
    public function getName()
16
    {
17
        return self::NAME;
18
    }
19
20
    /**
21
     * @param \ArrayObject $project
22
     *
23
     * @return mixed
24
     */
25
    public function create(\ArrayObject $project)
26
    {
27
28
    }
29
    /**
30
     * @return mixed
31
     */
32
    public function preMaintenance()
33
    {
34
        // TODO: Implement preMaintenance() method.
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public function postMaintenance()
41
    {
42
        // TODO: Implement postMaintenance() method.
43
    }
44
45
    /**
46
     * @param \ArrayObject $project
47
     *
48
     * @return mixed
49
     */
50
    public function maintenance(\ArrayObject $project)
51
    {
52
53
        $contactIds = $this->app["config"]["pingdom"]["contactids"];
54
        $username   = $this->app["config"]["pingdom"]["username"];
55
        $password   = $this->app["config"]["pingdom"]["password"];
56
        $token      = $this->app["config"]["pingdom"]["token"];
57
58
        if (!(empty($contactIds) && empty($username) && empty($password) && empty($token))){
59
            $pingdom = new \Pingdom\Client($username, $password, $token);
60
61
            $checkId=$pingdom->getCheck($project['name']);
62
            if (!is_null($checkId)){
63
                $pingdom->updateHTTPCheck($checkId, $project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
64
            }else{
65
                $pingdom->addHTTPCheck($project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
66
            }
67
        }
68
    }
69
70
    /**
71
     * @param \ArrayObject $project
72
     *
73
     * @return mixed
74
     */
75
    public function preBackup(\ArrayObject $project)
76
    {
77
        // TODO: Implement preBackup() method.
78
    }
79
80
    /**
81
     * @param \ArrayObject $project
82
     *
83
     * @return mixed
84
     */
85
    public function postBackup(\ArrayObject $project)
86
    {
87
        // TODO: Implement postBackup() method.
88
    }
89
90
    /**
91
     * @param \ArrayObject $project
92
     *
93
     * @return mixed
94
     */
95
    public function preRemove(\ArrayObject $project)
96
    {
97
        // TODO: Implement preRemove() method.
98
    }
99
100
    /**
101
     * @param \ArrayObject $project
102
     *
103
     * @return mixed
104
     */
105
    public function postRemove(\ArrayObject $project)
106
    {
107
        $username = $this->app["config"]["pingdom"]["username"];
108
        $password = $this->app["config"]["pingdom"]["password"];
109
        $token    = $this->app["config"]["pingdom"]["token"];
110
111
        if (!(empty($contactIds) && empty($username) && empty($password) && empty($token))){
0 ignored issues
show
Bug introduced by
The variable $contactIds seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
112
            $pingdom = new \Pingdom\Client($username, $password, $token);
113
114
            foreach ($pingdom->getAllChecks() as $key => $value) {
115
                if($value['name'] == $project['name']){
116
                    $pingdom->removeCheck($value['id']);
117
                }
118
            }
119
        }
120
    }
121
122
    /**
123
     * @return string[]
124
     */
125
    public function dependsOn()
126
    {
127
        return array("base", "apache");
128
    }
129
130
}
131