Faker\Provider\id_ID\Person::nik PHP Метод

nik() публичный Метод

Generates Nomor Induk Kependudukan (NIK)
public nik ( null | string $gender = null, null | DateTime $birthDate = null ) : string
$gender null | string
$birthDate null | DateTime
Результат string
    public function nik($gender = null, $birthDate = null)
    {
        # generate first numbers (region data)
        $nik = $this->generator->numerify('######');
        if (!$birthDate) {
            $birthDate = $this->generator->dateTimeBetween();
        }
        if (!$gender) {
            $gender = $this->generator->randomElement(array(self::GENDER_MALE, self::GENDER_FEMALE));
        }
        # if gender is female, add 40 to days
        if ($gender == self::GENDER_FEMALE) {
            $nik .= $birthDate->format('d') + 40;
        } else {
            $nik .= $birthDate->format('d');
        }
        $nik .= $birthDate->format('my');
        # add last random digits
        $nik .= $this->generator->numerify('####');
        return $nik;
    }