Passed
Push — master ( 61b2f8...584670 )
by Chubarov
05:03
created

Receipt::getProducts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Fns;
5
6
use Carbon\Carbon;
7
8
class Receipt
9
{
10
    private $data;
11
    private $products;
12
13
    public function __construct(string $json)
14
    {
15
        $this->data = json_decode($json);
16
        $this->products = new ProductCollection($this->data->content->items);
17
    }
18
19
    public function getProducts():ProductCollection
20
    {
21
        return $this->products;
22
    }
23
24
    public function getAddress():?string
25
    {
26
        return $this->data->content->retailPlaceAddress ?? $this->data->address ?? null;
27
    }
28
29
    public function getShopName():?string
30
    {
31
        return $this->data->content->user ?? null;
32
    }
33
34
    public function getShopInn() :int
35
    {
36
        return (int)$this->data->content->userInn;
37
    }
38
39
    public function getCashierName() :?string
40
    {
41
        return $this->data->content->operator ?? null;
42
    }
43
44
    public function getTotalSum():int
45
    {
46
        return $this->data->content->totalSum;
47
    }
48
49
    public function getKktRegId() :string
50
    {
51
        return $this->data->content->kktRegId;
52
    }
53
54
    public function getDataTimeString(): string
55
    {
56
        return Carbon::createFromTimestamp($this->data->content->dateTime, 'UTC')
57
                ->toDateTimeString();
58
    }
59
}
60