PHP 8.2.30
Preview: Payment.php Size: 10.42 KB
/home/byroehnu/easetack.com/vendor/fakerphp/faker/src/Faker/Provider/Payment.php

<?php

namespace Faker\Provider;

use Faker\Calculator\Iban;
use Faker\Calculator\Luhn;

class Payment extends Base
{
    public static $expirationDateFormat = 'm/y';

    protected static $cardVendors = [
        'Visa', 'Visa', 'Visa', 'Visa', 'Visa',
        'MasterCard', 'MasterCard', 'MasterCard', 'MasterCard', 'MasterCard',
        'American Express', 'Discover Card', 'Visa Retired', 'JCB',
    ];

    /**
     * @var array List of card brand masks for generating valid credit card numbers
     *
     * @see https://en.wikipedia.org/wiki/Payment_card_number Reference for existing prefixes
     * @see https://www.mastercard.us/en-us/issuers/get-support/2-series-bin-expansion.html MasterCard 2017 2-Series BIN Expansion
     */
    protected static $cardParams = [
        'Visa' => [
            '4539###########',
            '4556###########',
            '4916###########',
            '4532###########',
            '4929###########',
            '40240071#######',
            '4485###########',
            '4716###########',
            '4##############',
        ],
        'Visa Retired' => [
            '4539########',
            '4556########',
            '4916########',
            '4532########',
            '4929########',
            '40240071####',
            '4485########',
            '4716########',
            '4###########',
        ],
        'MasterCard' => [
            '2221###########',
            '23#############',
            '24#############',
            '25#############',
            '26#############',
            '2720###########',
            '51#############',
            '52#############',
            '53#############',
            '54#############',
            '55#############',
        ],
        'American Express' => [
            '34############',
            '37############',
        ],
        'Discover Card' => [
            '6011###########',
        ],
        'JCB' => [
            '3528###########',
            '3589###########',
        ],
    ];

    /**
     * @var array list of IBAN formats, source: @see https://www.swift.com/standards/data-standards/iban
     */
    protected static $ibanFormats = [
        'AD' => [['n', 4],    ['n', 4],  ['c', 12]],
        'AE' => [['n', 3],    ['n', 16]],
        'AL' => [['n', 8],    ['c', 16]],
        'AT' => [['n', 5],    ['n', 11]],
        'AZ' => [['a', 4],    ['c', 20]],
        'BA' => [['n', 3],    ['n', 3],  ['n', 8],  ['n', 2]],
        'BE' => [['n', 3],    ['n', 7],  ['n', 2]],
        'BG' => [['a', 4],    ['n', 4],  ['n', 2],  ['c', 8]],
        'BH' => [['a', 4],    ['c', 14]],
        'BR' => [['n', 8],    ['n', 5],  ['n', 10], ['a', 1],  ['c', 1]],
        'CH' => [['n', 5],    ['c', 12]],
        'CR' => [['n', 4],    ['n', 14]],
        'CY' => [['n', 3],    ['n', 5],  ['c', 16]],
        'CZ' => [['n', 4],    ['n', 6],  ['n', 10]],
        'DE' => [['n', 8],    ['n', 10]],
        'DK' => [['n', 4],    ['n', 9],  ['n', 1]],
        'DO' => [['c', 4],    ['n', 20]],
        'EE' => [['n', 2],    ['n', 2],  ['n', 11], ['n', 1]],
        'EG' => [['n', 4],    ['n', 4],  ['n', 17]],
        'ES' => [['n', 4],    ['n', 4],  ['n', 1],  ['n', 1],  ['n', 10]],
        'FI' => [['n', 6],    ['n', 7],  ['n', 1]],
        'FR' => [['n', 5],    ['n', 5],  ['c', 11], ['n', 2]],
        'GB' => [['a', 4],    ['n', 6],  ['n', 8]],
        'GE' => [['a', 2],    ['n', 16]],
        'GI' => [['a', 4],    ['c', 15]],
        'GR' => [['n', 3],    ['n', 4],  ['c', 16]],
        'GT' => [['c', 4],    ['c', 20]],
        'HR' => [['n', 7],    ['n', 10]],
        'HU' => [['n', 3],    ['n', 4],  ['n', 1],  ['n', 15], ['n', 1]],
        'IE' => [['a', 4],    ['n', 6],  ['n', 8]],
        'IL' => [['n', 3],    ['n', 3],  ['n', 13]],
        'IS' => [['n', 4],    ['n', 2],  ['n', 6],  ['n', 10]],
        'IT' => [['a', 1],    ['n', 5],  ['n', 5],  ['c', 12]],
        'KW' => [['a', 4],    ['n', 22]],
        'KZ' => [['n', 3],    ['c', 13]],
        'LB' => [['n', 4],    ['c', 20]],
        'LI' => [['n', 5],    ['c', 12]],
        'LT' => [['n', 5],    ['n', 11]],
        'LU' => [['n', 3],    ['c', 13]],
        'LV' => [['a', 4],    ['c', 13]],
        'MC' => [['n', 5],    ['n', 5],  ['c', 11], ['n', 2]],
        'MD' => [['c', 2],    ['c', 18]],
        'ME' => [['n', 3],    ['n', 13], ['n', 2]],
        'MK' => [['n', 3],    ['c', 10], ['n', 2]],
        'MR' => [['n', 5],    ['n', 5],  ['n', 11], ['n', 2]],
        'MT' => [['a', 4],    ['n', 5],  ['c', 18]],
        'MU' => [['a', 4],    ['n', 2],  ['n', 2],  ['n', 12], ['n', 3],  ['a', 3]],
        'NL' => [['a', 4],    ['n', 10]],
        'NO' => [['n', 4],    ['n', 6],  ['n', 1]],
        'PK' => [['a', 4],    ['c', 16]],
        'PL' => [['n', 8],    ['n', 16]],
        'PS' => [['a', 4],    ['c', 21]],
        'PT' => [['n', 4],    ['n', 4],  ['n', 11], ['n', 2]],
        'RO' => [['a', 4],    ['c', 16]],
        'RS' => [['n', 3],    ['n', 13], ['n', 2]],
        'SA' => [['n', 2],    ['c', 18]],
        'SE' => [['n', 3],    ['n', 16], ['n', 1]],
        'SI' => [['n', 5],    ['n', 8],  ['n', 2]],
        'SK' => [['n', 4],    ['n', 6],  ['n', 10]],
        'SM' => [['a', 1],    ['n', 5],  ['n', 5],  ['c', 12]],
        'TN' => [['n', 2],    ['n', 3],  ['n', 13], ['n', 2]],
        'TR' => [['n', 5],    ['n', 1],  ['c', 16]],
        'VG' => [['a', 4],    ['n', 16]],
    ];

    /**
     * @return string Returns a credit card vendor name
     *
     * @example 'MasterCard'
     */
    public static function creditCardType()
    {
        return static::randomElement(static::$cardVendors);
    }

    /**
     * Returns the String of a credit card number.
     *
     * @param string $type      Supporting any of 'Visa', 'MasterCard', 'American Express', 'Discover' and 'JCB'
     * @param bool   $formatted Set to true if the output string should contain one separator every 4 digits
     * @param string $separator Separator string for formatting card number. Defaults to dash (-).
     *
     * @return string
     *
     * @example '4485480221084675'
     */
    public static function creditCardNumber($type = null, $formatted = false, $separator = '-')
    {
        if (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;
    }

    /**
     * @param bool $valid True (by default) to get a valid expiration date, false to get a maybe valid date
     *
     * @return \DateTime
     *
     * @example 04/13
     */
    public function creditCardExpirationDate($valid = true)
    {
        if ($valid) {
            return $this->generator->dateTimeBetween('now', '36 months');
        }

        return $this->generator->dateTimeBetween('-36 months', '36 months');
    }

    /**
     * @param bool   $valid                True (by default) to get a valid expiration date, false to get a maybe valid date
     * @param string $expirationDateFormat
     *
     * @return string
     *
     * @example '04/13'
     */
    public function creditCardExpirationDateString($valid = true, $expirationDateFormat = null)
    {
        return $this->creditCardExpirationDate($valid)->format(null === $expirationDateFormat ? static::$expirationDateFormat : $expirationDateFormat);
    }

    /**
     * @param bool $valid True (by default) to get a valid expiration date, false to get a maybe valid date
     *
     * @return array
     */
    public function creditCardDetails($valid = true)
    {
        $type = static::creditCardType();

        return [
            'type' => $type,
            'number' => static::creditCardNumber($type),
            'name' => $this->generator->name(),
            'expirationDate' => $this->creditCardExpirationDateString($valid),
        ];
    }

    /**
     * International Bank Account Number (IBAN)
     *
     * @see http://en.wikipedia.org/wiki/International_Bank_Account_Number
     *
     * @param string $countryCode ISO 3166-1 alpha-2 country code
     * @param string $prefix      for generating bank account number of a specific bank
     * @param int    $length      total length without country code and 2 check digits
     *
     * @return string
     */
    public static function iban($countryCode = null, $prefix = '', $length = null)
    {
        $countryCode = null === $countryCode ? self::randomKey(self::$ibanFormats) : strtoupper($countryCode);

        $format = !isset(static::$ibanFormats[$countryCode]) ? null : static::$ibanFormats[$countryCode];

        if ($length === null) {
            if ($format === null) {
                $length = 24;
            } else {
                $length = 0;

                foreach ($format as $part) {
                    [$class, $groupCount] = $part;
                    $length += $groupCount;
                }
            }
        }

        if ($format === null) {
            $format = [['n', $length]];
        }

        $expandedFormat = '';

        foreach ($format as $item) {
            [$class, $length] = $item;
            $expandedFormat .= str_repeat($class, $length);
        }

        $result = $prefix;
        $expandedFormat = substr($expandedFormat, strlen($result));

        foreach (str_split($expandedFormat) as $class) {
            switch ($class) {
                default:
                case 'c':
                    $result .= Miscellaneous::boolean() ? static::randomDigit() : strtoupper(static::randomLetter());

                    break;

                case 'a':
                    $result .= strtoupper(static::randomLetter());

                    break;

                case 'n':
                    $result .= static::randomDigit();

                    break;
            }
        }

        $checksum = Iban::checksum($countryCode . '00' . $result);

        return $countryCode . $checksum . $result;
    }

    /**
     * Return the String of a SWIFT/BIC number
     *
     * @example 'RZTIAT22263'
     *
     * @see    http://en.wikipedia.org/wiki/ISO_9362
     *
     * @return string Swift/Bic number
     */
    public static function swiftBicNumber()
    {
        return self::regexify('^([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?$');
    }
}

Directory Contents

Dirs: 75 × Files: 20

Name Size Perms Modified Actions
ar_EG DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ar_JO DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ar_SA DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
at_AT DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
bg_BG DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
bn_BD DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
cs_CZ DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
da_DK DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
de_AT DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
de_CH DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
de_DE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
el_CY DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
el_GR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_AU DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_CA DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_GB DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_HK DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_IN DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_NG DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_NZ DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_PH DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_SG DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_UG DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_US DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
en_ZA DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
es_AR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
es_ES DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
es_PE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
es_VE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
et_EE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fa_IR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fi_FI DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fr_BE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fr_CA DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fr_CH DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
fr_FR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
he_IL DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
hr_HR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
hu_HU DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
hy_AM DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
id_ID DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
is_IS DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
it_CH DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
it_IT DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ja_JP DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ka_GE DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
kk_KZ DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ko_KR DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
lt_LT DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
lv_LV DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
me_ME DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
mn_MN DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
ms_MY DIR
- drwxrwxrwx 2025-05-16 16:14:39
Edit Download
nb_NO DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
ne_NP DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
nl_BE DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
nl_NL DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
pl_PL DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
pt_BR DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
pt_PT DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
ro_MD DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
ro_RO DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
ru_RU DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
sk_SK DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
sl_SI DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
sr_RS DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
sv_SE DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
th_TH DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
tr_TR DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
uk_UA DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
vi_VN DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
zh_CN DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
zh_TW DIR
- drwxrwxrwx 2025-05-16 16:14:40
Edit Download
3.49 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
2.19 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
22.20 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
1.79 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
4.64 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
901 B lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
12.10 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
25.10 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
9.98 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
6.00 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
17.17 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
7.70 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
648 B lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
13.21 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
10.42 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
3.23 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
6.45 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
6.65 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
8.46 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download
1.78 KB lrw-rw-rw- 2024-11-21 13:46:39
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).