These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | * Default permissions level |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $permission_level = ['read' => '#organization:read', 'edit' => '#organization:edit']; |
||
26 | |||
27 | /** |
||
28 | * List access rules (permission needed: #organization:read) |
||
29 | * Search, sort, and filter IP/country access rules |
||
30 | * |
||
31 | * @param string $organization_id |
||
32 | * @param string|null $mode The action to apply to a matched request |
||
33 | * @param string|null $configuration_target The rule configuration target |
||
34 | * @param string|null $configuration_value Search by IP, range, or country code |
||
35 | * @param int|null $page Page number of paginated results |
||
36 | * @param int|null $per_page Number of rules per page |
||
37 | * @param string|null $order Field to order rules by |
||
38 | * @param string|null $direction Direction to order rules |
||
39 | * @param string|null $match Whether to match all search requirements or at least one (any) |
||
40 | */ |
||
41 | public function rules($organization_id, $mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) |
||
42 | { |
||
43 | $data = [ |
||
0 ignored issues
–
show
|
|||
44 | 'mode' => $mode, |
||
45 | 'configuration_target' => $configuration_target, |
||
46 | 'configuration_value' => $configuration_value, |
||
47 | 'page' => $page, |
||
48 | 'per_page' => $per_page, |
||
49 | 'order' => $order, |
||
50 | 'direction' => $direction, |
||
51 | 'match' => $match, |
||
52 | ]; |
||
53 | return $this->get('organizations/'.$organization_id.'/firewall/access_rules/rules'); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Create access rule (permission needed: #organization:edit) |
||
58 | * Make a new IP, IP range, or country access rule for all zones owned by the organization. |
||
59 | * Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints. |
||
60 | * |
||
61 | * @param string $organization_id |
||
62 | * @param string $mode The action to apply to a matched request |
||
63 | * @param object $configuration Rule configuration |
||
64 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. |
||
65 | */ |
||
66 | public function create($organization_id, $mode, $configuration, $notes = null) |
||
67 | { |
||
68 | $data = [ |
||
69 | 'mode' => $mode, |
||
70 | 'configuration' => $configuration, |
||
71 | 'notes' => $notes, |
||
72 | ]; |
||
73 | |||
74 | return $this->post('organizations/'.$organization_id.'/firewall/access_rules/rules', $data); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Update access rule (permission needed: #organization:edit) |
||
79 | * Update rule state and/or configuration. This will be applied across all zones owned by the organization. |
||
80 | * |
||
81 | * @param string $organization_id |
||
82 | * @param string $identifier |
||
83 | * @param string|null $mode The action to apply to a matched request |
||
84 | * @param object|null $configuration Rule configuration |
||
85 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. |
||
86 | */ |
||
87 | public function update($organization_id, $identifier, $mode = null, $configuration = null, $notes = null) |
||
88 | { |
||
89 | $data = [ |
||
90 | 'mode' => $mode, |
||
91 | 'configuration' => $configuration, |
||
92 | 'notes' => $notes, |
||
93 | ]; |
||
94 | |||
95 | return $this->patch('organizations/'.$organization_id.'/firewall/access_rules/rules/'.$identifier, $data); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Delete access rule (permission needed: #organization:edit) |
||
100 | * Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the organization |
||
101 | * |
||
102 | * @param string $organization_id |
||
103 | * @param string $identifier |
||
104 | */ |
||
105 | public function delete_rule($organization_id, $identifier) |
||
106 | { |
||
107 | return $this->delete('organizations/'.$organization_id.'/firewall/access_rules/rules/'.$identifier); |
||
108 | } |
||
109 | } |
||
110 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.