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

SetupIntent::cancel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class SetupIntent
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property string $application
11
 * @property string $client_secret
12
 * @property int $created
13
 * @property string $customer
14
 * @property string $description
15
 * @property mixed $last_setup_error
16
 * @property bool $livemode
17
 * @property StripeObject $metadata
18
 * @property mixed $next_action
19
 * @property string $on_behalf_of
20
 * @property string $payment_method
21
 * @property string[] $payment_method_types
22
 * @property string $status
23
 *
24
 * @package Stripe
25
 */
26
class SetupIntent extends ApiResource
27
{
28
29
    const OBJECT_NAME = "setup_intent";
30
31
    use ApiOperations\All;
32
    use ApiOperations\Create;
33
    use ApiOperations\Retrieve;
34
    use ApiOperations\Update;
35
36
    /**
37
     * These constants are possible representations of the status field.
38
     *
39
     * @link https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status
40
     */
41
    const STATUS_CANCELED                = 'canceled';
42
    const STATUS_PROCESSING              = 'processing';
43
    const STATUS_REQUIRES_ACTION         = 'requires_action';
44
    const STATUS_REQUIRES_CONFIRMATION   = 'requires_confirmation';
45
    const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
46
    const STATUS_SUCCEEDED               = 'succeeded';
47
48
    /**
49
     * @param array|null $params
50
     * @param array|string|null $options
51
     *
52
     * @return SetupIntent The canceled setup intent.
53
     */
54
    public function cancel($params = null, $options = null)
55
    {
56
        $url = $this->instanceUrl() . '/cancel';
57
        list($response, $opts) = $this->_request('post', $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...
58
        $this->refreshFrom($response, $opts);
59
        return $this;
60
    }
61
62
    /**
63
     * @param array|null $params
64
     * @param array|string|null $options
65
     *
66
     * @return SetupIntent The confirmed setup intent.
67
     */
68
    public function confirm($params = null, $options = null)
69
    {
70
        $url = $this->instanceUrl() . '/confirm';
71
        list($response, $opts) = $this->_request('post', $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...
72
        $this->refreshFrom($response, $opts);
73
        return $this;
74
    }
75
}
76