Completed
Pull Request — master (#1)
by Carlos C
02:06
created

ReportCreditResult::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok\Services\Utilities;
6
7
use PhpCfdi\Finkok\Services\AbstractResult;
8
use stdClass;
9
10
class ReportCreditResult extends AbstractResult
11
{
12
    /** @var array[] */
13
    private $items;
14
15 3
    public function __construct(stdClass $data)
16
    {
17 3
        parent::__construct($data, 'report_creditResult');
18 3
        $this->items = [];
19
20 3
        $items = $this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit');
21 3
        if (! is_array($items)) {
22 1
            $items = [];
23
        }
24 3
        foreach ($items as $item) {
25 2
            $this->items[] = [
26 2
                'credit' => strval($item->credit),
27 2
                'date' => strval($item->date),
28
            ];
29
        }
30 3
    }
31
32
    /** @return array[] */
33 3
    public function items(): array
34
    {
35 3
        return $this->items;
36
    }
37
38
    public function error(): string
39
    {
40
        return $this->get('error');
41
    }
42
}
43