Completed
Push — master ( ce2be0...7bcb9a )
by Olivier
02:08
created

Discount   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 64
ccs 8
cts 18
cp 0.4444
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 11 2
A getCoupon() 0 4 1
A getCustomer() 0 4 1
A getEndAt() 0 4 1
A getStartAt() 0 4 1
A getSubscription() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Shapin\Stripe\Model\Discount;
11
12
use Shapin\Stripe\Model\Coupon\Coupon;
13
use Shapin\Stripe\Model\CreatableFromArray;
14
15
final class Discount implements CreatableFromArray
16
{
17
    /**
18
     * @var Coupon
19
     */
20
    private $coupon;
21
22
    /**
23
     * @var string
24
     */
25
    private $customer;
26
27
    /**
28
     * @var ?\DateTimeImmutable
29
     */
30
    private $endAt;
31
32
    /**
33
     * @var \DateTimeImmutable
34
     */
35
    private $startAt;
36
37
    /**
38
     * @var string
39
     */
40
    private $subscription;
41
42 3
    public static function createFromArray(array $data): self
43
    {
44 3
        $model = new self();
45 3
        $model->coupon = Coupon::createFromArray($data['coupon']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Cou...mArray($data['coupon']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\Coupon\Coupon> of property $coupon.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46 3
        $model->customer = $data['customer'];
47 3
        $model->endAt = isset($data['end']) ? new \DateTimeImmutable('@'.$data['end']) : null;
48 3
        $model->startAt = new \DateTimeImmutable('@'.$data['start']);
49 3
        $model->subscription = $data['subscription'];
50
51 3
        return $model;
52
    }
53
54
    public function getCoupon(): Coupon
55
    {
56
        return $this->coupon;
57
    }
58
59
    public function getCustomer(): string
60
    {
61
        return $this->customer;
62
    }
63
64
    public function getEndAt(): ?\DateTimeImmutable
65
    {
66
        return $this->endAt;
67
    }
68
69
    public function getStartAt(): \DateTimeImmutable
70
    {
71
        return $this->startAt;
72
    }
73
74
    public function getSubscription(): string
75
    {
76
        return $this->subscription;
77
    }
78
}
79