Completed
Push — master ( ff4385...64b1f6 )
by Dragos
14:18
created

Subscription::setCoupon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Speicher210\Fastbill\Api\Model;
4
5
use JMS\Serializer\Annotation as JMS;
6
7
/**
8
 * Subscription model.
9
 */
10
class Subscription
11
{
12
    use SubscriptionTrait;
13
14
    const SUBSCRIPTION_STATUS_ACTIVE = 'active';
15
16
    /**
17
     * Inactive subscription, usually after a payment failed.
18
     */
19
    const SUBSCRIPTION_STATUS_INACTIVE = 'inactive';
20
21
    /**
22
     * While in the trial period.
23
     */
24
    const SUBSCRIPTION_STATUS_TRIAL = 'trial';
25
26
    /**
27
     * If it has reached the cancellation date.
28
     */
29
    const SUBSCRIPTION_STATUS_CANCELED = 'canceled';
30
31
    /**
32
     * If the subscription is closed.
33
     */
34
    const SUBSCRIPTION_STATUS_CLOSED = 'closed';
35
36
    /**
37
     * The coupon applied to the subscription.
38
     *
39 18
     * @var Coupon
40
     *
41
     * @JMS\Type("Speicher210\Fastbill\Api\Model\Coupon")
42 18
     * @JMS\SerializedName("COUPON")
43
     */
44 18
    protected $coupon;
45
46 18
    /**
47
     * Get the coupon for the subscription.
48
     *
49
     * @return Coupon
50
     */
51
    public function getCoupon()
52
    {
53
        return $this->coupon;
54
    }
55
56
    /**
57
     * Set the coupon.
58
     *
59
     * @param Coupon $coupon The coupon to set.
60
     */
61
    public function setCoupon(Coupon $coupon)
62
    {
63
        $this->coupon = $coupon;
64
    }
65
    
66
    /**
67
     * Check if the current subscription is running.
68
     *
69
     * @return boolean
70
     */
71
    public function isRunning()
72
    {
73
        $runningStatuses = array(
74
            self::SUBSCRIPTION_STATUS_ACTIVE,
75
            self::SUBSCRIPTION_STATUS_TRIAL,
76
        );
77
78
        return in_array($this->getStatus(), $runningStatuses);
79
    }
80
}
81