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

Item   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 89.47%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 67
ccs 17
cts 19
cp 0.8947
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 12 1
A getId() 0 4 1
A getCreatedAt() 0 4 1
A getPlan() 0 4 1
A getQuantity() 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\Subscription;
11
12
use Shapin\Stripe\Model\ContainsMetadata;
13
use Shapin\Stripe\Model\CreatableFromArray;
14
use Shapin\Stripe\Model\MetadataTrait;
15
use Shapin\Stripe\Model\MetadataCollection;
16
use Shapin\Stripe\Model\Plan\Plan;
17
18
final class Item implements CreatableFromArray, ContainsMetadata
19
{
20
    use MetadataTrait;
21
22
    /**
23
     * @var string
24
     */
25
    private $id;
26
27
    /**
28
     * @var \DateTimeImmutable
29
     */
30
    private $createdAt;
31
32
    /**
33
     * @var Plan
34
     */
35
    private $plan;
36
37
    /**
38
     * @var int
39
     */
40
    private $quantity;
41
42
    /**
43
     * @var string
44
     */
45
    private $subscription;
46
47 7
    public static function createFromArray(array $data): self
48
    {
49 7
        $model = new self();
50 7
        $model->id = $data['id'];
51 7
        $model->createdAt = new \DateTimeImmutable('@'.$data['created']);
52 7
        $model->metadata = MetadataCollection::createFromArray($data['metadata']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Met...rray($data['metadata']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\MetadataCollection> of property $metadata.

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...
53 7
        $model->plan = Plan::createFromArray($data['plan']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Pla...romArray($data['plan']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\Plan\Plan> of property $plan.

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...
54 7
        $model->quantity = (int) $data['quantity'];
55 7
        $model->subscription = $data['subscription'];
56
57 7
        return $model;
58
    }
59
60 1
    public function getId(): string
61
    {
62 1
        return $this->id;
63
    }
64
65 1
    public function getCreatedAt(): \DateTimeImmutable
66
    {
67 1
        return $this->createdAt;
68
    }
69
70
    public function getPlan(): Plan
71
    {
72
        return $this->plan;
73
    }
74
75 1
    public function getQuantity(): int
76
    {
77 1
        return $this->quantity;
78
    }
79
80 1
    public function getSubscription(): string
81
    {
82 1
        return $this->subscription;
83
    }
84
}
85