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.

Zones::search_sort_paginate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 15

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 12

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Cloudflare\User\Billing\Subscriptions;
4
5
use Cloudflare\Api;
6
use Cloudflare\User;
7
8
/**
9
 * CloudFlare API wrapper
10
 *
11
 * Billing
12
 * Zone Subscription
13
 *
14
 * @author James Bell <[email protected]>
15
 *
16
 * @version 1
17
 */
18 View Code Duplication
class Zones extends Api
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
    /**
21
     * List (permission needed: #billing:read)
22
     * List all of your zone plan subscriptions
23
     */
24
    public function list_zones()
25
    {
26
        return $this->get('/user/billing/subscriptions/zones');
27
    }
28
29
    /**
30
     * Search, sort, and paginate (permission needed: #billing:read)
31
     * Search, sort, and paginate your subscriptions
32
     *
33
     * @param int|null    $page         Page number of paginated results
34
     * @param int|null    $per_page     Number of items per page
35
     * @param string|null $order        Field to order subscriptions by
36
     * @param string|null $status       The state of the subscription
37
     * @param string|null $price        The price of the subscription that will be billed, in US dollars
38
     * @param string|null $activated_on When the subscription was activated
39
     * @param string|null $expires_on   When the subscription will expire
40
     * @param string|null $expired_on   When the subscription expired
41
     * @param string|null $cancelled_on When the subscription was cancelled
42
     * @param string|null $renewed_on   When the subscription was renewed
43
     * @param string|null $direction    Direction to order subscriptions
44
     * @param string|null $match        Whether to match all search requirements or at least one (any)
45
     */
46
    public function search_sort_paginate($page = null, $per_page = null, $order = null, $status = null, $price = null, $activated_on = null, $expires_on = null, $expired_on = null, $cancelled_on = null, $renewed_on = null, $direction = null, $match = null)
47
    {
48
        $data = [
49
            'page'         => $page,
50
            'per_page'     => $per_page,
51
            'order'        => $order,
52
            'status'       => $status,
53
            'price'        => $price,
54
            'activated_on' => $activated_on,
55
            'expires_on'   => $expires_on,
56
            'expired_on'   => $expired_on,
57
            'cancelled_on' => $cancelled_on,
58
            'renewed_on'   => $renewed_on,
59
            'direction'    => $direction,
60
            'match'        => $match,
61
        ];
62
63
        return $this->get('/user/billing/subscriptions/zones', $data);
64
    }
65
66
    /**
67
     * Info (permission needed: #billing:read)
68
     * Billing subscription details
69
     *
70
     * @param string $identifier API item identifier tag
71
     */
72
    public function info($identifier)
73
    {
74
        return $this->get('/user/billing/subscriptions/zones/'.$identifier);
75
    }
76
}
77