TaxRate::createFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 13
cts 13
cp 1
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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\TaxRate;
11
12
use Shapin\Stripe\Model\ContainsMetadata;
13
use Shapin\Stripe\Model\CreatableFromArray;
14
use Shapin\Stripe\Model\LivemodeTrait;
15
use Shapin\Stripe\Model\MetadataCollection;
16
use Shapin\Stripe\Model\MetadataTrait;
17
18
final class TaxRate implements CreatableFromArray, ContainsMetadata
19
{
20
    use LivemodeTrait;
21
    use MetadataTrait;
22
23
    /**
24
     * @var string
25
     */
26
    private $id;
27
28
    /**
29
     * @var bool
30
     */
31
    private $isActive;
32
33
    /**
34
     * @var \DateTimeImmutable
35
     */
36
    private $createdAt;
37
38
    /**
39
     * @var ?string
40
     */
41
    private $description;
42
43
    /**
44
     * @var string
45
     */
46
    private $displayName;
47
48
    /**
49
     * @var bool
50
     */
51
    private $isInclusive;
52
53
    /**
54
     * @var ?string
55
     */
56
    private $jurisdiction;
57
58
    /**
59
     * @var float
60
     */
61
    private $percentage;
62
63 2
    public static function createFromArray(array $data): self
64
    {
65 2
        $model = new self();
66
67 2
        $model->id = $data['id'];
68 2
        $model->isActive = (bool) $data['active'];
69 2
        $model->createdAt = new \DateTimeImmutable('@'.$data['created']);
70 2
        $model->description = $data['description'];
71 2
        $model->displayName = $data['display_name'];
72 2
        $model->isInclusive = (bool) $data['inclusive'];
73 2
        $model->jurisdiction = $data['jurisdiction'];
74 2
        $model->live = $data['livemode'];
75 2
        $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...
76 2
        $model->percentage = $data['percentage'];
77
78 2
        return $model;
79
    }
80
81 1
    public function getId(): string
82
    {
83 1
        return $this->id;
84
    }
85
86 1
    public function isActive(): bool
87
    {
88 1
        return $this->isActive;
89
    }
90
91 1
    public function getCreatedAt(): \DateTimeImmutable
92
    {
93 1
        return $this->createdAt;
94
    }
95
96 1
    public function getDescription(): ?string
97
    {
98 1
        return $this->description;
99
    }
100
101 1
    public function getDisplayName(): string
102
    {
103 1
        return $this->displayName;
104
    }
105
106 1
    public function isInclusive(): bool
107
    {
108 1
        return $this->isInclusive;
109
    }
110
111 1
    public function getJurisdiction(): ?string
112
    {
113 1
        return $this->jurisdiction;
114
    }
115
116 1
    public function getPercentage(): float
117
    {
118 1
        return $this->percentage;
119
    }
120
}
121