Completed
Push — master ( c98fe8...bf7ad8 )
by Joachim
05:52
created

PaymentNatureService::hydrateXml()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
namespace Loevgaard\AltaPay\Entity;
3
4
use Loevgaard\AltaPay\Hydrator\HydratableInterface;
5
6
class PaymentNatureService implements HydratableInterface
7
{
8
    /**
9
     * @var string
10
     */
11
    private $name;
12
13
    /**
14
     * @var boolean
15
     */
16
    private $supportsRefunds;
17
18
    /**
19
     * @var boolean
20
     */
21
    private $supportsRelease;
22
23
    /**
24
     * @var boolean
25
     */
26
    private $supportsMultipleCaptures;
27
28
    /**
29
     * @var boolean
30
     */
31
    private $supportsMultipleRefunds;
32
33
    /**
34
     * @return string
35
     */
36 3
    public function getName() : string
37
    {
38 3
        return $this->name;
39
    }
40
41
    /**
42
     * @return bool
43
     */
44 3
    public function isSupportsRefunds() : bool
45
    {
46 3
        return $this->supportsRefunds;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52 3
    public function isSupportsRelease() : bool
53
    {
54 3
        return $this->supportsRelease;
55
    }
56
57
    /**
58
     * @return bool
59
     */
60 3
    public function isSupportsMultipleCaptures() : bool
61
    {
62 3
        return $this->supportsMultipleCaptures;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68 3
    public function isSupportsMultipleRefunds() : bool
69
    {
70 3
        return $this->supportsMultipleRefunds;
71
    }
72
73 27
    public function hydrateXml(\SimpleXMLElement $xml)
74
    {
75 27
        if (!isset($xml->PaymentNatureService)) {
76 9
            return;
77
        }
78
79 18
        $this->name = (string)$xml->PaymentNatureService['name'];
80 18
        $this->supportsRefunds = (string)$xml->PaymentNatureService->SupportsRefunds === 'true';
81 18
        $this->supportsRelease = (string)$xml->PaymentNatureService->SupportsRelease === 'true';
82 18
        $this->supportsMultipleCaptures = (string)$xml->PaymentNatureService->SupportsMultipleCaptures === 'true';
83 18
        $this->supportsMultipleRefunds = (string)$xml->PaymentNatureService->SupportsMultipleRefunds === 'true';
84 18
    }
85
}
86