Faker\Provider\Payment::creditCardNumber PHP Méthode

creditCardNumber() public static méthode

Returns the String of a credit card number.
public static creditCardNumber ( string $type = null, boolean $formatted = false, string $separator = '-' ) : string
$type string Supporting any of 'Visa', 'MasterCard', 'American Express', and 'Discover'
$formatted boolean Set to true if the output string should contain one separator every 4 digits
$separator string Separator string for formatting card number. Defaults to dash (-).
Résultat string
    public static function creditCardNumber($type = null, $formatted = false, $separator = '-')
    {
        if (is_null($type)) {
            $type = static::creditCardType();
        }
        $mask = static::randomElement(static::$cardParams[$type]);
        $number = static::numerify($mask);
        $number .= Luhn::computeCheckDigit($number);
        if ($formatted) {
            $p1 = substr($number, 0, 4);
            $p2 = substr($number, 4, 4);
            $p3 = substr($number, 8, 4);
            $p4 = substr($number, 12);
            $number = $p1 . $separator . $p2 . $separator . $p3 . $separator . $p4;
        }
        return $number;
    }