Completed
Push — master ( a004d3...9bce71 )
by Hannes
02:34
created

FakeId::getBirthCounty()   A

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
3
namespace byrokrat\id;
4
5
/**
6
 * Fake personal identity numbers
7
 *
8
 * Fake ids replace serial number post delimiter with xxxx. If sex should be
9
 * encoded xx1x or xx2x can be used.
10
 */
11
class FakeId extends PersonalId
12
{
13
    /**
14
     * Regular expression describing id structure
15
     */
16
    const PATTERN = '/^((?:\d\d)?)(\d{6})([-+]?)(xx[12x])(x)$/i';
17
18
    /**
19
     * Fake personal identity numbers
20
     *
21
     * {@inheritdoc}
22
     *
23
     * @param string $number
24
     */
25 34
    public function __construct($number)
26
    {
27 34
        list(, $century, $datestr, $delimiter, $serialPost, $check) = $this->parseNumber(self::PATTERN, $number);
28 12
        parent::__construct($century . $datestr . $delimiter . '0000');
29 12
        $this->serialPost = $serialPost;
30 12
        $this->checkDigit = $check;
31 12
    }
32
33 1
    public function getSex()
34
    {
35 1
        return is_numeric($this->getSerialPostDelimiter()[2]) ? parent::getSex() : self::SEX_UNDEFINED;
36
    }
37
38 1
    public function getBirthCounty()
39
    {
40 1
        return IdInterface::COUNTY_UNDEFINED;
41
    }
42
43
    /**
44
     * Fake ids always have valid check digits
45
     */
46 12
    protected function validateCheckDigit()
47
    {
48 12
    }
49
}
50