Вход Регистрация
Файл: vendor/fakerphp/faker/src/Faker/Provider/el_GR/PhoneNumber.php
Строк: 377
<?php

namespace FakerProviderel_GR;

/**
 * @see https://en.wikipedia.org/wiki/Telephone_numbers_in_Greece
 * @see https://github.com/giggsey/libphonenumber-for-php/blob/master/src/data/PhoneNumberMetadata_GR.php
 */
class PhoneNumber extends FakerProviderPhoneNumber
{
    protected static 
$internationalCallPrefixes = ['''+30'];

    protected static 
$formats = [
        
'{{fixedLineNumber}}',
        
'{{mobileNumber}}',
        
'{{personalNumber}}',
        
'{{tollFreeNumber}}',
        
'{{sharedCostNumber}}',
        
'{{premiumRateNumber}}',
    ];

    protected static 
$areaCodes = [
        
// Zone 22: Central Greece and the Aegean Islands
        
22212222222322242226222722282229,
        
22312232223322342235223622372238,
        
2241224222432244224522462247,
        
2251225222532254,
        
22612262226322642265226622672268,
        
22712272227322742275,
        
228122822283228422852286228722882289,
        
229122922293229422952296229722982299,

        
// Zone 23: Central Macedonia and Florina
        
231,
        
232123222323232423252327,
        
233123322333,
        
23412343,
        
235123522353,
        
2371237223732374237523762377,
        
23812382238423852386,
        
23912392239323942395239623972399,

        
// Zone 24: Thessaly and West Macedonia (excluding Florina)
        
241,
        
24212422242324242425242624272428,
        
2431243224332434,
        
2441244324442445,
        
2461246224632464246524672468,
        
24912492249324942495,

        
// Zone 25: East Macedonia and Thrace
        
251,
        
2521252225232524,
        
25312532253325342535,
        
254125422544,
        
2591259225932594,
        
255125522553255425552556,

        
// Zone 26: West Greece, Ionian Island and Epirus
        
261,
        
262126222623262426252626,
        
2631263226342635,
        
266126622663266426652666,
        
269126922693269426952696,
        
2641264226432644264526462647,
        
26512653265426552656265726582659,
        
26712674,
        
26812682268326842685,

        
// Zone 27: Peloponnese and Kythera
        
271,
        
27212722272327242725,
        
273127322733273427352736,
        
2741274227432744274527462747,
        
275127522753275427552757,
        
276127632765,
        
2791279227952797,

        
// Zone 28: Crete
        
281,
        
28212822282328242825,
        
2831283228332834,
        
2841284228432844,
        
289128922893289428952897,
    ];

    protected static 
$fixedLineFormats = [
        
'{{internationalCodePrefix}}21########',
        
'{{internationalCodePrefix}} 21# ### ####',
        
'{{internationalCodePrefix}}{{areaCode}}######',
        
'{{internationalCodePrefix}} {{areaCode}} ######',
    ];

    protected static 
$mobileCodes = [
        
685687688689,
        
690691693694695696697698699,
    ];

    protected static 
$mobileFormats = [
        
'{{internationalCodePrefix}}{{mobileCode}}#######',
        
'{{internationalCodePrefix}} {{mobileCode}} ### ####',
    ];

    protected static 
$personalFormats = [
        
'{{internationalCodePrefix}}70########',
        
'{{internationalCodePrefix}} 70 #### ####',
    ];

    protected static 
$tollFreeFormats = [
        
'{{internationalCodePrefix}}800#######',
        
'{{internationalCodePrefix}} 800 ### ####',
    ];

    protected static 
$sharedCostCodes = [801806812825850875];

    protected static 
$sharedCostFormats = [
        
'{{internationalCodePrefix}}{{sharedCostCode}}#######',
        
'{{internationalCodePrefix}} {{sharedCostCode}} ### ####',
    ];

    protected static 
$premiumRateCodes = [901909];

    protected static 
$premiumRateFormats = [
        
'{{internationalCodePrefix}}{{premiumRateCode}}#######',
        
'{{internationalCodePrefix}} {{premiumRateCode}} ### ####',
    ];

    
/**
     * Generate a country calling code prefix.
     *
     * @example Prefix an empty string: ''
     * @example Prefix the country calling code: '+30'
     *
     * @internal Used to generate phone numbers with or without prefixes.
     *
     * @return string
     */
    
public static function internationalCodePrefix()
    {
        return static::
randomElement(static::$internationalCallPrefixes);
    }

    
/**
     * Generate an area code for a fixed line number.
     *
     * Doesn't include codes for Greater Athens Metropolitan Area (21#) because
     * this zone uses 3 digits, and phone numbers have a different formatting.
     *
     * Area codes in all the other zones use 4 digits.
     * The capital of each zone uses 3 digits and the 4th digit can be any number.
     * The other areas in each zone use 4 digits, but not every number is valid for the 4th digit.
     *
     * @example Thessaloniki has code '231', so '2310' and '2313' are valid.
     * @example Serres has code '232', but '2326', '2328' and '2329' are not valid.
     *
     * @return string
     */
    
public static function areaCode()
    {
        return static::
numerify(
            
str_pad(static::randomElement(static::$areaCodes), 4'#'),
        );
    }

    
/**
     * Generate a fixed line number.
     *
     * Numbers can be generated with or without the international code prefix.
     * Numbers can be generated with or without spaces between their parts.
     * Numbers in Athens use a 3-digit area code, and can be formatted as 21# ### ####.
     * Numbers in other areas use a 4-digit area code, and can be formatted as 2### ### ###.
     *
     * @example A number in Athens: '2101234567'
     * @example A number in Thessaloniki: '2310123456'
     * @example A number with spaces in Athens: '210 123 4567'
     * @example A number with spaces in Thessaloniki: '2310 123 456'
     * @example A number with international code prefix: '+302101234567'
     * @example A number with international code prefix and spaces: '+30 2310 123 456'
     *
     * @return string
     */
    
public function fixedLineNumber()
    {
        return 
ltrim(static::numerify($this->generator->parse(
            static::
randomElement(static::$fixedLineFormats),
        )));
    }

    
/**
     * Generate a code for a mobile number.
     *
     * @internal Used to generate mobile numbers.
     *
     * @return string
     */
    
public static function mobileCode()
    {
        return static::
randomElement(static::$mobileCodes);
    }

    
/**
     * Generate a mobile number.
     *
     * @example A mobile number: '6901234567'
     * @example A mobile number with spaces: '690 123 4567'
     * @example A mobile number with international code prefix: '+306901234567'
     * @example A mobile number with international code prefix and spaces: '+30 690 123 4567'
     *
     * @return string
     */
    
public function mobileNumber()
    {
        return 
ltrim(static::numerify($this->generator->parse(
            static::
randomElement(static::$mobileFormats),
        )));
    }

    
/**
     * @deprecated Use PhoneNumber::mobileNumber() instead.
     */
    
public static function mobilePhoneNumber()
    {
        return static::
numerify(
            
strtr(static::randomElement(static::$mobileFormats), [
                
'{{internationalCodePrefix}}' => static::internationalCodePrefix(),
                
'{{mobileCode}}' => static::mobileCode(),
            ]),
        );
    }

    
/**
     * Generate a personal number.
     *
     * @example A personal number: '7012345678'
     * @example A personal number with spaces: '70 1234 5678'
     * @example A personal number with international code prefix: '+307012345678'
     * @example A personal number with international code prefix and spaces: '+30 70 1234 5678'
     *
     * @return string
     */
    
public function personalNumber()
    {
        return 
ltrim(static::numerify($this->generator->parse(
            static::
randomElement(static::$personalFormats),
        )));
    }

    
/**
     * Generate a toll-free number.
     *
     * @example A toll-free number: '8001234567'
     * @example A toll-free number with spaces: '800 123 4567'
     * @example A toll-free number with international code prefix: '+308001234567'
     * @example A toll-free number with international code prefix and spaces: '+30 800 123 4567'
     *
     * @return string
     */
    
public static function tollFreeNumber()
    {
        return 
ltrim(static::numerify(
            
strtr(static::randomElement(static::$tollFreeFormats), [
                
'{{internationalCodePrefix}}' => static::internationalCodePrefix(),
            ]),
        ));
    }

    
/**
     * Generate a code for a shared-cost number.
     *
     * @internal Used to generate shared-cost numbers.
     *
     * @return string
     */
    
public static function sharedCostCode()
    {
        return static::
randomElement(static::$sharedCostCodes);
    }

    
/**
     * Generate a shared-cost number.
     *
     * @example A shared-cost number: '8011234567'
     * @example A shared-cost number with spaces: '801 123 4567'
     * @example A shared-cost number with international code prefix: '+308011234567'
     * @example A shared-cost number with international code prefix and spaces: '+30 801 123 4567'
     *
     * @return string
     */
    
public function sharedCostNumber()
    {
        return 
ltrim(static::numerify($this->generator->parse(
            static::
randomElement(static::$sharedCostFormats),
        )));
    }

    
/**
     * Generate a code for a premium-rate number.
     *
     * @internal Used to generate premium-rate numbers.
     *
     * @return string
     */
    
public static function premiumRateCode()
    {
        return static::
randomElement(static::$premiumRateCodes);
    }

    
/**
     * Generate a premium-rate number.
     *
     * @example A premium-rate number: '9011234567'
     * @example A premium-rate number with spaces: '901 123 4567'
     * @example A premium-rate number with international code prefix: '+309011234567'
     * @example A premium-rate number with international code prefix and spaces: '+30 901 123 4567'
     *
     * @return string
     */
    
public function premiumRateNumber()
    {
        return 
ltrim(static::numerify($this->generator->parse(
            static::
randomElement(static::$premiumRateFormats),
        )));
    }
}
Онлайн: 0
Реклама