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

CreditNote   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A voidCreditNote() 0 7 1
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class CreditNote
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property int $amount
11
 * @property string $customer_balance_transaction
12
 * @property int $created
13
 * @property string $currency
14
 * @property string $customer
15
 * @property string $invoice
16
 * @property bool $livemode
17
 * @property string $memo
18
 * @property StripeObject $metadata
19
 * @property string $number
20
 * @property string $pdf
21
 * @property string $reason
22
 * @property string $refund
23
 * @property string $status
24
 * @property string $type
25
 *
26
 * @package Stripe
27
 */
28
class CreditNote extends ApiResource
29
{
30
31
    const OBJECT_NAME = "credit_note";
32
33
    use ApiOperations\All;
34
    use ApiOperations\Create;
35
    use ApiOperations\Retrieve;
36
    use ApiOperations\Update;
37
38
    /**
39
     * Possible string representations of the credit note reason.
40
     * @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-reason
41
     */
42
    const REASON_DUPLICATE              = 'duplicate';
43
    const REASON_FRAUDULENT             = 'fraudulent';
44
    const REASON_ORDER_CHANGE           = 'order_change';
45
    const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory';
46
47
    /**
48
     * Possible string representations of the credit note status.
49
     * @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
50
     */
51
    const STATUS_ISSUED = 'issued';
52
    const STATUS_VOID   = 'void';
53
54
    /**
55
     * Possible string representations of the credit note type.
56
     * @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
57
     */
58
    const TYPE_POST_PAYMENT = 'post_payment';
59
    const TYPE_PRE_PAYMENT  = 'pre_payment';
60
61
    /**
62
     * @param array|null $params
63
     * @param array|string|null $opts
64
     *
65
     * @return CreditNote The voided credit note.
66
     */
67
    public function voidCreditNote($params = null, $opts = null)
68
    {
69
        $url = $this->instanceUrl() . '/void';
70
        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...
71
        $this->refreshFrom($response, $opts);
72
        return $this;
73
    }
74
}
75