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
Pull Request — master (#87)
by
unknown
18:17
created

UserAgentRules::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 5
1
<?php
2
3
namespace Cloudflare\Zone\Firewall;
4
5
use Cloudflare\Api;
6
7
/**
8
 * CloudFlare API wrapper
9
 *
10
 * Firewall user agent rules for a Zone
11
 *
12
 * @author  Alexander Fedra <[email protected]>
13
 *
14
 * @version 1
15
 */
16
class UserAgentRules extends Api
17
{
18
    /**
19
     * List user agent rules (permission needed: #zone:read)
20
     * List the UserAgent rules on a zone.
21
     *
22
     * @param string      $zone_id
23
     * @param int|null    $page        Page number of paginated results.
24
     * @param int|null    $per_page    Number of UserAgent rules per page.
25
     * @param string|null $user_agent  A single UserAgent string to search for.
26
     * @param string|null $description A single string to search for in the description.
27
     *
28
     * @return mixed
29
     */
30
    public function rules($zone_id, $page = null, $per_page = null, $user_agent = null, $description = null)
31
    {
32
        $data = [
33
            'page'        => $page,
34
            'per_page'    => $per_page,
35
            'user_agent'  => $user_agent,
36
            'description' => $description,
37
        ];
38
39
        return $this->get('/zones/' . $zone_id . '/firewall/ua_rules', $data);
40
    }
41
42
    /**
43
     * Show user agent rule details (permission needed: #zone:read)
44
     *
45
     * @param string $zone_id
46
     * @param string $identifier
47
     *
48
     * @return mixed
49
     */
50
    public function rule($zone_id, $identifier)
51
    {
52
        return $this->get('/zones/' . $zone_id . '/firewall/ua_rules/' . $identifier);
53
    }
54
55
    /**
56
     * Create user agent rule (permission needed: #zone:edit)
57
     * Create a new UserAgent rule for a zone. See the record object definitions for required attributes for each
58
     * record type.
59
     *
60
     * @param string      $zone_id
61
     * @param string      $mode          The type of action to perform.
62
     * @param object      $configuration Target/Value pair to use for this rule. The value is the exact UserAgent to
63
     *                                   match.
64
     * @param bool|null   $paused        Whether this UA rule is currently paused.
65
     * @param string|null $description   Some useful information about this rule to help identify the purpose of it.
66
     *
67
     * @return mixed
68
     */
69 View Code Duplication
    public function create($zone_id, $mode, $configuration, $paused = 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...
70
    {
71
        $data = [
72
            'mode'          => $mode,
73
            'configuration' => $configuration,
74
            'paused'        => $paused,
75
            'description'   => $description,
76
        ];
77
78
        return $this->post('/zones/' . $zone_id . '/firewall/ua_rules', $data);
79
    }
80
81
    /**
82
     * Update user agent rule (permission needed: #zone:edit)
83
     * Update a UserAgent rule for a zone. See the record object definitions for required attributes for each
84
     * record type.
85
     *
86
     * @param string      $zone_id
87
     * @param string      $identifier
88
     * @param string      $mode          The type of action to perform.
89
     * @param object      $configuration Target/Value pair to use for this rule. The value is the exact UserAgent to
90
     *                                   match.
91
     * @param bool|null   $paused        Whether this UA rule is currently paused.
92
     * @param string|null $description   Some useful information about this rule to help identify the purpose of it.
93
     *
94
     * @return mixed
95
     */
96 View Code Duplication
    public function update($zone_id, $identifier, $mode, $configuration, $paused, $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...
97
    {
98
        $data = [
99
            'mode'          => $mode,
100
            'configuration' => $configuration,
101
            'paused'        => $paused,
102
            'description'   => $description,
103
        ];
104
105
        return $this->patch('/zones/' . $zone_id . '/firewall/ua_rules/' . $identifier, $data);
106
    }
107
108
    /**
109
     * Delete agent rule (permission needed: #zone:edit)
110
     *
111
     * @param string $zone_id
112
     * @param string $identifier
113
     *
114
     * @return mixed
115
     */
116
    public function delete_rule($zone_id, $identifier)
117
    {
118
        return $this->delete('/zones/' . $zone_id . '/firewall/ua_rules/' . $identifier);
119
    }
120
}
121