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.

Monitors   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 110
Duplicated Lines 15.45 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 17
loc 110
rs 10
c 2
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A monitors() 0 4 1
A create() 0 17 1
A details() 0 4 1
A update() 17 17 1
A delete_monitor() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Cloudflare\User\LoadBalancers;
4
5
use Cloudflare\Api;
6
use Cloudflare\User;
7
8
/**
9
 * CloudFlare API wrapper
10
 *
11
 * CTM Monitors
12
 * Cloud Traffic Manager Monitor
13
 *
14
 * @author James Bell <[email protected]>
15
 *
16
 * @version 1
17
 */
18
class Monitors extends Api
19
{
20
    /**
21
     * List monitors
22
     * List configured monitors for a user
23
     */
24
    public function monitors()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
25
    {
26
        return $this->get('/user/load_balancers/monitors');
27
    }
28
29
    /**
30
     * Create a monitor
31
     * Create a configured monitor
32
     *
33
     * @param string      $expected_body  A case-insensitive substring to match in the body of the probe
34
     *                                    response to declare an origin as up
35
     * @param string      $expected_codes The expected HTTP response code or code range for the probe
36
     * @param string|null $method         The HTTP method to use for the health check.
37
     * @param int|null    $timeout        The timeout (in seconds) before marking the health check as failed
38
     * @param string|null $path           The endpoint path to health check against.
39
     * @param int|null    $interval       The interval between each health check. Shorter intervals may improve failover
40
     *                                    time, but will increase load on the origins as we check from multiple locations.
41
     * @param int|null    $retries        The number of retries to attempt in case of a timeout before marking the origin
42
     *                                    as unhealthy. Retries are attempted immediately.
43
     * @param array|null  $header         The HTTP request headers to send in the health check. It is recommended you set
44
     *                                    a Host header by default. The User-Agent header cannot be overridden.
45
     * @param int|null    $type           The protocol to use for the healthcheck. Currently supported protocols are
46
     *                                    'HTTP' and 'HTTPS'.
47
     * @param string|null $description    Object description
48
     */
49
    public function create($expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null)
50
    {
51
        $data = [
52
            'expected_body'  => $expected_body,
53
            'expected_codes' => $expected_codes,
54
            'method'         => $method,
55
            'timeout'        => $timeout,
56
            'path'           => $path,
57
            'interval'       => $interval,
58
            'retries'        => $retries,
59
            'header'         => $header,
60
            'type'           => $type,
61
            'description'    => $description,
62
        ];
63
64
        return $this->post('/user/load_balancers/monitors', $data);
65
    }
66
67
    /**
68
     * Monitor details
69
     * List a single configured CTM monitor for a user
70
     *
71
     * @param string $identifier
72
     */
73
    public function details($identifier)
74
    {
75
        return $this->get('/user/load_balancers/monitors/'.$identifier);
76
    }
77
78
    /**
79
     * Modify a monitor
80
     * Modify a configured monitor
81
     *
82
     * @param string      $identifier
83
     * @param string      $expected_body  A case-insensitive substring to match in the body of the probe
84
     *                                    response to declare an origin as up
85
     * @param string      $expected_codes The expected HTTP response code or code range for the probe
86
     * @param string|null $method         The HTTP method to use for the health check.
87
     * @param int|null    $timeout        The timeout (in seconds) before marking the health check as failed
88
     * @param string|null $path           The endpoint path to health check against.
89
     * @param int|null    $interval       The interval between each health check. Shorter intervals may improve failover
90
     *                                    time, but will increase load on the origins as we check from multiple locations.
91
     * @param int|null    $retries        The number of retries to attempt in case of a timeout before marking the origin
92
     *                                    as unhealthy. Retries are attempted immediately.
93
     * @param array|null  $header         The HTTP request headers to send in the health check. It is recommended you set
94
     *                                    a Host header by default. The User-Agent header cannot be overridden.
95
     * @param int|null    $type           The protocol to use for the healthcheck. Currently supported protocols are
96
     *                                    'HTTP' and 'HTTPS'.
97
     * @param string|null $description    Object description
98
     */
99 View Code Duplication
    public function update($identifier, $expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
100
    {
101
        $data = [
102
            'expected_body'  => $expected_body,
103
            'expected_codes' => $expected_codes,
104
            'method'         => $method,
105
            'timeout'        => $timeout,
106
            'path'           => $path,
107
            'interval'       => $interval,
108
            'retries'        => $retries,
109
            'header'         => $header,
110
            'type'           => $type,
111
            'description'    => $description,
112
        ];
113
114
        return $this->patch('/user/load_balancers/monitors/'.$identifier, $data);
115
    }
116
117
    /**
118
     * Delete a monitor
119
     * Delete a configured monitor
120
     *
121
     * @param string $identifier
122
     */
123
    public function delete_monitor($identifier)
124
    {
125
        return $this->delete('/user/load_balancers/monitors/'.$identifier);
126
    }
127
}
128