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.

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