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

CancelledDocument   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 48
ccs 18
cts 18
cp 1
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A documentStatus() 0 3 1
A uuid() 0 3 1
A __construct() 0 3 1
A get() 0 3 1
A cancellationStatus() 0 3 1
A cancellationSatatus() 0 7 1
A values() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok\Services\Cancel;
6
7
use stdClass;
8
9
class CancelledDocument
10
{
11
    /** @var stdClass */
12
    private $data;
13
14 12
    public function __construct(stdClass $raw)
15
    {
16 12
        $this->data = $raw;
17 12
    }
18
19 8
    private function get(string $keyword): string
20
    {
21 8
        return strval($this->data->{$keyword} ?? '');
22
    }
23
24 7
    public function uuid(): string
25
    {
26 7
        return $this->get('UUID');
27
    }
28
29 1
    public function documentStatus(): string
30
    {
31 1
        return $this->get('EstatusUUID');
32
    }
33
34
    /**
35
     * @return string
36
     * @deprecated 0.3.2
37
     * @see self::cancellationStatus
38
     */
39 2
    public function cancellationSatatus(): string
40
    {
41 2
        trigger_error(
42 2
            sprintf('%s is deprecated since 0.3.2 and will be removed on 0.4.0', __METHOD__),
43 2
            E_USER_DEPRECATED
44
        );
45 1
        return $this->cancellationStatus();
46
    }
47
48 2
    public function cancellationStatus(): string
49
    {
50 2
        return $this->get('EstatusCancelacion');
51
    }
52
53
    /** @return array<mixed> */
54 2
    public function values(): array
55
    {
56 2
        return (array) $this->data;
57
    }
58
}
59