Passed
Push — master ( f78dc8...d3e9de )
by Carlos C
46s queued 12s
created

ReportUuidResult   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 13
c 3
b 0
f 0
dl 0
loc 35
ccs 12
cts 15
cp 0.8
rs 10
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 ReportUuidResult extends AbstractResult
11
{
12
    /** @var array[] */
13
    private $items;
14
15 2
    public function __construct(stdClass $data)
16
    {
17 2
        parent::__construct($data, 'report_uuidResult');
18 2
        $this->items = [];
19
20 2
        $items = $this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID');
21 2
        if (! is_array($items)) {
22
            $items = [];
23
        }
24 2
        foreach ($items as $item) {
25 2
            $this->items[] = [
26 2
                'date' => strval($item->date),
27 2
                'uuid' => strval($item->uuid),
28
            ];
29
        }
30 2
    }
31
32
    /**
33
     * The returned array contains an array with keys date (string) and uuid (string)
34
     *
35
     * @return array[]
36
     */
37 2
    public function items(): array
38
    {
39 2
        return $this->items;
40
    }
41
42
    public function error(): string
43
    {
44
        return $this->get('error');
45
    }
46
}
47