Passed
Push — master ( a8e753...d3e13e )
by Carlos C
05:06 queued 03:16
created

ReportCreditResult   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 31
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A items() 0 3 1
A error() 0 3 1
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 4
    public function __construct(stdClass $data)
16
    {
17 4
        parent::__construct($data, 'report_creditResult');
18 4
        $this->items = [];
19
20 4
        $items = $this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit');
21 4
        if (! is_array($items)) {
22 2
            $items = [];
23
        }
24 4
        foreach ($items as $item) {
25 2
            $this->items[] = [
26 2
                'credit' => strval($item->credit),
27 2
                'date' => strval($item->date),
28
            ];
29
        }
30 4
    }
31
32
    /** @return array[] */
33 3
    public function items(): array
34
    {
35 3
        return $this->items;
36
    }
37
38 1
    public function error(): string
39
    {
40 1
        return $this->get('error');
41
    }
42
}
43