CreditCardExpiry::getYear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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 36
    public function hydrateXml(\SimpleXMLElement $xml)
19
    {
20 36
        if (!isset($xml->CreditCardExpiry)) {
21 30
            return;
22
        }
23
24 6
        $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 6
        $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 6
    }
27
28
    /**
29
     * @return int
30
     */
31 6
    public function getYear(): ?int
32
    {
33 6
        return $this->year;
34
    }
35
36
    /**
37
     * @return int
38
     */
39 6
    public function getMonth(): ?int
40
    {
41 6
        return $this->month;
42
    }
43
}
44