forked from byrokrat/id
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FakeId.php
51 lines (45 loc) · 1.16 KB
/
FakeId.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace byrokrat\id;
/**
* Fake personal identity numbers
*
* Fake ids replace serial number post delimiter with xxxx. If sex should be
* encoded xx1x or xx2x can be used.
*/
class FakeId extends PersonalId
{
use Component\BirthCounty;
/**
* @var string Regular expression describing structure
*/
protected static $structure = '/^((?:\d\d)?)(\d{6})([-+]?)(xx[12x])(x)$/i';
/**
* {@inheritdoc}
*
* @param string $number
*/
public function __construct($number)
{
list(, $century, $datestr, $delimiter, $serialPost, $check) = FakeId::parseStructure($number);
parent::__construct($century . $datestr . $delimiter . '0000');
$this->serialPost = $serialPost;
$this->checkDigit = $check;
}
/**
* {@inheritdoc}
*
* @return string One of the sex identifier constants
*/
public function getSex()
{
return is_numeric($this->getSerialPostDelimiter()[2]) ? parent::getSex() : self::SEX_UNDEFINED;
}
/**
* Fake ids always have valid check digits
*
* @return void
*/
protected function validateCheckDigit()
{
}
}