Passed
Push — master ( c1a9cf...81fe5a )
by Matthew
04:50
created

Stripe::updateSchedule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 2
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MySociety\TheyWorkForYou;
4
5
class Stripe {
6
    private static $instance;
7
8 1
    public function __construct($stripeSecretKey) {
9 1
        if (self::$instance) {
10
            throw new \RuntimeException('Stripe could not be instantiate more than once. Check PHP implementation : https://github.com/stripe/stripe-php');
11
        }
12 1
        self::$instance = $this;
13
14 1
        \Stripe\Stripe::setApiKey($stripeSecretKey);
15 1
        \Stripe\Stripe::setApiVersion(STRIPE_API_VERSION);
0 ignored issues
show
Bug introduced by
The constant MySociety\TheyWorkForYou\STRIPE_API_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
16
    }
17
18
    public function getSubscription($args) {
19
        return \Stripe\Subscription::retrieve($args);
20
    }
21
22
    public function getUpcomingInvoice($args) {
23
        return \Stripe\Invoice::upcoming($args);
24
    }
25
26
    public function createCustomer($args) {
27
        return \Stripe\Customer::create($args);
28
    }
29
30
    public function updateCustomer($id, $args) {
31
        return \Stripe\Customer::update($id, $args);
32
    }
33
34
    public function createSubscription($args) {
35
        return \Stripe\Subscription::create($args);
36
    }
37
38
    public function getInvoices($args) {
39
        return \Stripe\Invoice::all($args);
40
    }
41
42
    public function createSchedule($id) {
43
        return \Stripe\SubscriptionSchedule::create(['from_subscription' => $id]);
44
    }
45
46
    public function updateSchedule($id, $phases) {
47
        return \Stripe\SubscriptionSchedule::update($id, ['phases' => $phases]);
48
    }
49
50
    public function releaseSchedule($id) {
51
        \Stripe\SubscriptionSchedule::release($id);
0 ignored issues
show
Bug Best Practice introduced by
The method Stripe\SubscriptionSchedule::release() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        \Stripe\SubscriptionSchedule::/** @scrutinizer ignore-call */ 
52
                                      release($id);
Loading history...
52
    }
53
54
    public function updateSubscription($id, $args) {
55
        \Stripe\Subscription::update($id, $args);
56
    }
57
}
58