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

ThresholdReason::createFromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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\Invoice;
11
12
use Shapin\Stripe\Model\CreatableFromArray;
13
14
final class ThresholdReason implements CreatableFromArray
15
{
16
    /**
17
     * @var int
18
     */
19
    private $amountGte;
20
21
    /**
22
     * @var array
23
     */
24
    private $itemReasons;
25
26
    public static function createFromArray(array $data): self
27
    {
28
        $itemReasons = [];
29
        foreach ($data['item_reasons'] as $itemReason) {
30
            $itemReasons[] = ThresholdItemReason::createFromArray($itemReason);
31
        }
32
33
        $model = new self();
34
        $model->amountGte = (int) $data['amount_gte'];
35
        $model->itemReasons = $itemReasons;
36
37
        return $model;
38
    }
39
40
    public function getAmountGte(): int
41
    {
42
        return $this->amountGte;
43
    }
44
45
    public function getItemReasons(): array
46
    {
47
        return $this->itemReasons;
48
    }
49
}
50