ReportUuidResult::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.009

Importance

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