TransformUsage::createFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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\Plan;
11
12
use Shapin\Stripe\Model\CreatableFromArray;
13
14
final class TransformUsage implements CreatableFromArray
15
{
16
    const ROUND_UP = 'up';
17
    const ROUND_DOWN = 'down';
18
19
    /**
20
     * @var int
21
     */
22
    private $divideBy;
23
24
    /**
25
     * @var string
26
     */
27
    private $round;
28
29
    public static function createFromArray(array $data): self
30
    {
31
        $model = new self();
32
        $model->divideBy = (int) $data['divide_by'];
33
        $model->round = $data['round'];
34
35
        return $model;
36
    }
37
38
    public function getDivideBy(): int
39
    {
40
        return $this->divideBy;
41
    }
42
43
    public function getRound(): string
44
    {
45
        return $this->round;
46
    }
47
}
48