Completed
Push — master ( ad55a4...c98fe8 )
by Joachim
01:57
created

CreditCardExpiry::hydrateXml()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.5

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 3
cts 6
cp 0.5
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2.5
1
<?php
2
namespace Loevgaard\AltaPay\Entity;
3
4
use Loevgaard\AltaPay\Hydrator\HydratableInterface;
5
6
class CreditCardExpiry implements HydratableInterface
7
{
8
    /**
9
     * @var int
10
     */
11
    private $year;
12
13
    /**
14
     * @var int
15
     */
16
    private $month;
17
18 9
    public function hydrateXml(\SimpleXMLElement $xml)
19
    {
20 9
        if(!isset($xml->CreditCardExpiry)) {
21 9
            return;
22
        }
23
24
        $this->year = (string)$xml->CreditCardExpiry->Year;
0 ignored issues
show
Documentation Bug introduced by
The property $year was declared of type integer, but (string) $xml->CreditCardExpiry->Year is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
25
        $this->month = (string)$xml->CreditCardExpiry->Month;
0 ignored issues
show
Documentation Bug introduced by
The property $month was declared of type integer, but (string) $xml->CreditCardExpiry->Month is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
26
    }
27
}
28