Test Failed
Push — master ( 3dd85e...34f16b )
by Devin
04:34 queued 10s
created

SubscriptionSchedule   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 81
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A cancel() 0 7 1
A release() 0 7 1
A revisions() 0 8 1
A retrieveRevision() 0 4 1
A allRevisions() 0 4 1
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class SubscriptionSchedule
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property string $billing
11
 * @property mixed $billing_thresholds
12
 * @property int $canceled_at
13
 * @property int $completed_at
14
 * @property int $created
15
 * @property mixed $current_phase
16
 * @property string $customer
17
 * @property mixed $invoice_settings
18
 * @property boolean $livemode
19
 * @property StripeObject $metadata
20
 * @property mixed $phases
21
 * @property int $released_at
22
 * @property string $released_subscription
23
 * @property string $renewal_behavior
24
 * @property mixed $renewal_interval
25
 * @property string $revision
26
 * @property string $status
27
 * @property string $subscription
28
 *
29
 * @package Stripe
30
 */
31
class SubscriptionSchedule extends ApiResource
32
{
33
34
    const OBJECT_NAME = "subscription_schedule";
35
36
    use ApiOperations\All;
37
    use ApiOperations\Create;
38
    use ApiOperations\Retrieve;
39
    use ApiOperations\Update;
40
    use ApiOperations\NestedResource;
41
42
    const PATH_REVISIONS = '/revisions';
43
44
    /**
45
     * @param array|null $params
46
     * @param array|string|null $opts
47
     *
48
     * @return SubscriptionSchedule The canceled subscription schedule.
49
     */
50
    public function cancel($params = null, $opts = null)
51
    {
52
        $url = $this->instanceUrl() . '/cancel';
53
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
54
        $this->refreshFrom($response, $opts);
55
        return $this;
56
    }
57
58
    /**
59
     * @param array|null $params
60
     * @param array|string|null $opts
61
     *
62
     * @return SubscriptionSchedule The released subscription schedule.
63
     */
64
    public function release($params = null, $opts = null)
65
    {
66
        $url = $this->instanceUrl() . '/release';
67
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
68
        $this->refreshFrom($response, $opts);
69
        return $this;
70
    }
71
72
    /**
73
     * @param array|null $params
74
     * @param array|string|null $options
75
     *
76
     * @return Collection The list of subscription schedule revisions.
77
     */
78
    public function revisions($params = null, $options = null)
79
    {
80
        $url = $this->instanceUrl() . '/revisions';
81
        list($response, $opts) = $this->_request('get', $url, $params, $options);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
82
        $obj = Util\Util::convertToStripeObject($response, $opts);
83
        $obj->setLastResponse($response);
84
        return $obj;
85
    }
86
87
    /**
88
     * @param array|null $id The ID of the subscription schedule to which the person belongs.
89
     * @param array|null $personId The ID of the person to retrieve.
90
     * @param array|null $params
91
     * @param array|string|null $opts
92
     *
93
     * @return Revision
94
     */
95
    public static function retrieveRevision($id, $personId, $params = null, $opts = null)
96
    {
97
        return self::_retrieveNestedResource($id, static::PATH_REVISIONS, $personId, $params, $opts);
0 ignored issues
show
Documentation introduced by
$id is of type array|null, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $personId defined by parameter $personId on line 95 can also be of type array; however, Stripe\ApiOperations\Nes...etrieveNestedResource() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
98
    }
99
100
    /**
101
     * @param array|null $id The ID of the subscription schedule on which to retrieve the persons.
102
     * @param array|null $params
103
     * @param array|string|null $opts
104
     *
105
     * @return Collection The list of revisions.
106
     */
107
    public static function allRevisions($id, $params = null, $opts = null)
108
    {
109
        return self::_allNestedResources($id, static::PATH_REVISIONS, $params, $opts);
0 ignored issues
show
Documentation introduced by
$id is of type array|null, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
110
    }
111
}
112