TransformUsage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 34
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 8 1
A getDivideBy() 0 4 1
A getRound() 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\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