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.

AccessRules::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 4
1
<?php
2
3
namespace Cloudflare\User\Firewall;
4
5
use Cloudflare\Api;
6
use Cloudflare\User;
7
8
/**
9
 * CloudFlare API wrapper
10
 *
11
 * User-level Firewall access rule
12
 *
13
 * @author James Bell <[email protected]>
14
 *
15
 * @version 1
16
 */
17
class AccessRules extends Api
18
{
19
    /**
20
     * List access rules (permission needed: #billing:read)
21
     * Search, sort, and filter IP/country access rules
22
     *
23
     * @param string|null $mode                 The action to apply to a matched request
24
     * @param string|null $configuration_target The rule configuration target
25
     * @param string|null $configuration_value  Search by IP, range, or country code
26
     * @param int|null    $page                 Page number of paginated results
27
     * @param int|null    $per_page             Number of items per page
28
     * @param string|null $order                Field to order rules by
29
     * @param string|null $direction            Direction to order rules
30
     * @param string|null $match                Whether to match all search requirements or at least one (any)
31
     */
32
    public function rules($mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = 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...
33
    {
34
        $data = [
35
            'mode'                 => $mode,
36
            'configuration_target' => $configuration_target,
37
            'configuration_value'  => $configuration_value,
38
            'page'                 => $page,
39
            'per_page'             => $per_page,
40
            'order'                => $order,
41
            'direction'            => $direction,
42
            'match'                => $match,
43
        ];
44
45
        return $this->get('/user/firewall/access_rules/rules', $data);
46
    }
47
48
    /**
49
     * Create access rule (permission needed: #billing:edit)
50
     * Make a new IP, IP range, or country access rule for all zones owned by the user.
51
     * Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints.
52
     *
53
     * @param string      $mode          The action to apply to a matched request
54
     * @param object      $configuration Rule configuration
55
     * @param string|null $notes         A personal note about the rule. Typically used as a reminder or explanation for the rule.
56
     */
57
    public function create($mode, $configuration, $notes = 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...
58
    {
59
        $data = [
60
            'mode'          => $mode,
61
            'configuration' => $configuration,
62
            'notes'         => $notes,
63
        ];
64
65
        return $this->post('/user/firewall/access_rules/rules', $data);
66
    }
67
68
    /**
69
     * Update access rule (permission needed: #billing:edit)
70
     * Update rule state and/or configuration. This will be applied across all zones owned by the user.
71
     *
72
     * @param string      $identifier
73
     * @param string|null $mode          The action to apply to a matched request
74
     * @param object|null $configuration Rule configuration
75
     * @param string|null $notes         A personal note about the rule. Typically used as a reminder or explanation for the rule.
76
     */
77
    public function update($identifier, $mode = null, $configuration = null, $notes = null)
78
    {
79
        $data = [
80
            'mode'          => $mode,
81
            'configuration' => $configuration,
82
            'notes'         => $notes,
83
        ];
84
85
        return $this->patch('/user/firewall/access_rules/rules/'.$identifier, $data);
86
    }
87
88
    /**
89
     * Delete access rule (permission needed: #billing:edit)
90
     * Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the user
91
     *
92
     * @param string $identifier
93
     */
94
    public function delete_rule($identifier)
95
    {
96
        return $this->delete('/user/firewall/access_rules/rules/'.$identifier);
97
    }
98
}
99