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

SubscriptionItem::usageRecordSummaries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 8
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class SubscriptionItem
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property mixed $billing_thresholds
11
 * @property int $created
12
 * @property StripeObject $metadata
13
 * @property Plan $plan
14
 * @property int $quantity
15
 * @property string $subscription
16
 * @property array $tax_rates
17
 *
18
 * @package Stripe
19
 */
20 View Code Duplication
class SubscriptionItem extends ApiResource
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...
21
{
22
23
    const OBJECT_NAME = "subscription_item";
24
25
    use ApiOperations\All;
26
    use ApiOperations\Create;
27
    use ApiOperations\Delete;
28
    use ApiOperations\Retrieve;
29
    use ApiOperations\Update;
30
31
    /**
32
     * @param array|null $params
33
     * @param array|string|null $options
34
     *
35
     * @return Collection The list of source transactions.
36
     */
37
    public function usageRecordSummaries($params = null, $options = null)
38
    {
39
        $url = $this->instanceUrl() . '/usage_record_summaries';
40
        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...
41
        $obj = Util\Util::convertToStripeObject($response, $opts);
42
        $obj->setLastResponse($response);
43
        return $obj;
44
    }
45
}
46