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.
Completed
Push — master ( 13043e...cdd853 )
by Frédéric
01:53
created

HttpMonitoring   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 2
cbo 1
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getMetric() 0 7 3
A getUnit() 0 4 1
A getAlarms() 0 8 1
1
<?php
2
namespace CloudWatchScript\Plugins;
3
4
use CloudWatchScript\AbstractMonitoring;
5
6
/**
7
 * Check Solr using ping URL.
8
 * Add and configure the folliwong lines to the config file
9
 * "Http" : {
10
 *         "name" : "Name of metric and alarm",
11
 *         "url": "http://localhost:8080/solr/collection1/admin/ping",
12
 *         "pattern": "ds",
13
 *         "namespace": "Metric/Namespace",
14
 *         "description": "Descrption"
15
 * }
16
 */
17
class HttpMonitoring extends AbstractMonitoring
18
{
19
    private $url;
20
    private $pattern;
21
    /**
22
     * @param array $config
23
     * @param String $name
24
     */
25
    public function __construct($config, $name)
26
    {
27
        parent::__construct($config, $name);
28
        $this->url = $this->config->url;
29
        $this->pattern = $this->config->pattern;
30
    }
31
    /**
32
     * Check solr ping url.
33
     * @return metric 0 Ok, 1 KO
34
     */
35
    public function getMetric()
36
    {
37
        if ($result = @file_get_contents($this->url) === false) {
38
            return 0;
39
        }
40
        return ereg($result, $this->pattern)===true?"1":"0";
41
    }
42
    /**
43
     * @return string "None"
44
     */
45
    public function getUnit()
46
    {
47
        return "None";
48
    }
49
    /**
50
     * @return integer 1
51
     */
52
    public function getAlarms()
53
    {
54
        return array(
55
                    array("ComparisonOperator" => "LessThanThreshold",
56
                          "Threshold" => 1,
57
                          "Name" => $this->name)
58
                    );
59
    }
60
}
61