Completed
Push — master ( 37d52e...ca4941 )
by Jhao
11:04
created

Balance   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDate() 0 3 1
A getValue() 0 7 2
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Entities;
15
16
use Appwilio\RussianPostSDK\Dispatching\DataAware;
17
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
18
19
final class Balance implements Arrayable
20
{
21
    use DataAware;
22
23
    public function getValue(): float
24
    {
25
        if ($this->get('work-with-balance')) {
26
            return (float) $this->get('balance');
27
        }
28
29
        throw new \Exception($this->get('error-message'));
30
    }
31
32
    public function getDate(): \DateTimeImmutable
33
    {
34
        return \DateTimeImmutable::createFromFormat('Y-m-d', $this->get('balance-date'));
35
    }
36
}
37