Documentation

Company extends Company
in package

Table of Contents

$bsWords  : mixed
$catchPhrase  : mixed
$companyEnFormats  : mixed
$companyEnSuffix  : mixed
$companyModifier  : mixed
$companyPrefix  : mixed
$companySuffix  : mixed
$formats  : mixed
$generator  : Generator
$jobTitleFormat  : mixed
$unique  : UniqueGenerator
__construct()  : mixed
asciify()  : string
Replaces * signs with random numbers and letters and special characters
bothify()  : string
Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter
bs()  : mixed
catchPhrase()  : mixed
company()  : string
companyEn()  : mixed
companyEnSuffix()  : mixed
companyModifier()  : mixed
companyPrefix()  : mixed
companySuffix()  : string
jobTitle()  : string
lexify()  : string
Replaces all question mark ('?') occurrences with a random letter
numberBetween()  : int
Returns a random number between $int1 and $int2 (any order)
numerify()  : string
Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number
optional()  : mixed|null
Chainable method for making any formatter optional.
passthrough()  : mixed
Returns the passed value
randomAscii()  : string
Returns a random ASCII character (excluding accents and special chars)
randomDigit()  : int
Returns a random number between 0 and 9
randomDigitNot()  : int
Generates a random digit, which cannot be $except
randomDigitNotNull()  : int
Returns a random number between 1 and 9
randomElement()  : mixed
Returns a random element from a passed array
randomElements()  : array<string|int, mixed>
Returns randomly ordered subsequence of $count elements from a provided array
randomFloat()  : float
Return a random float number
randomKey()  : int|string|null
Returns a random key from a passed associative array
randomLetter()  : string
Returns a random letter from a to z
randomNumber()  : int
Returns a random integer with 0 to $nbDigits digits.
regexify()  : string
Transforms a basic regular expression into a random string satisfying the expression.
shuffle()  : array<string|int, mixed>|string
Returns a shuffled version of the argument.
shuffleArray()  : array<string|int, mixed>
Returns a shuffled version of the array.
shuffleString()  : string
Returns a shuffled version of the string.
toLower()  : string
Converts string to lowercase.
toUpper()  : string
Converts string to uppercase.
unique()  : UniqueGenerator
Chainable method for making any formatter unique.
valid()  : ValidGenerator
Chainable method for forcing any formatter to return only valid values.
VAT()  : int
return standard VAT / Tax ID / Uniform Serial Number
replaceWildcard()  : mixed

Properties

$bsWords

protected static mixed $bsWords = [['實現', '實作', '整合', '最佳化', '革命', '轉變', '提昇', '啟用', '指揮', '利用', '重現', '結合', '架構', '加強', '集中', '變形', '強化', '推廣', '延伸', '生產', '進化', '改善', '提高', '開發', '創造', '專注'], ['加值', '縱向', '堅固', '全球', '在地', '領先', '虛擬', '動態', '完全', '成熟', '穩定', '穩健', '即時', '全年無休', '高效', '快速', '互動', '世界級', '下一代', '新一代', '無線', '無限', '豐富', '開源', '前端', '分散式', '無縫', '跨平臺'], ['典範', '市場', '合作', '架構', '基礎平臺', '頻道', '焦點', '方案', '解決方案', '社群', '科技', '技術', '內容', '入口', '供應鍊', '介面', '系統', '頻寬', '模型', '網路', '使用經驗', '評量', '方法']]

$catchPhrase

protected static mixed $catchPhrase = ['Everything's ok', 'Just call me be happy', 'Keep Walking', 'NOKIA相信科技始終來自於人性', 'PayEasy,陪你Shopping一輩子', 'Play不累', 'The city never sleeps', 'Trust me, you can make it!', 'We are family', 'We share', 'You A.S.O beautiful', '一人吃,兩人補', '一定要幸福哦!', '一把抵兩把,何需瑪麗亞?!', '一次買好,就是頂好', '一步一腳印,大家愛台灣', '一段話,感動了一幅畫!', '一點一點 累積更好的自己', '三不五時,愛要及時', '三餐老是在外,人人叫我老外!', '不只辦公室,掌握更多事', '不在乎天長地久,只在乎曾經擁有', '不在辦公室,也能辦公事', '不平凡的平凡大眾', '不想分開 就永遠在一起吧', '不該愛的,趁早換', '不過~不過~,一定測不過', '世事難料,安泰比較好', '世事難料,對人要更好', '世界上最重要的一部車是爸爸的肩膀', '乎乾啦!', '人生30財開始', '什麼最青?', '什麼都有,什麼都賣,什麼都不奇怪!', '今天心情幾?', '他傻瓜、你聰明', '他捉得住我', '你未必出類拔萃 但肯定與眾不同', '你的愛,是孩子最好的示範', '你講台語嘛也通', '便宜一樣有好貨', '係金A!', '信任,帶來新幸福', '信義房屋,信任,帶來新幸福', '做你自己才叫乖,做你的乖乖!', '做自己 自己做', '傻瓜鏡片,聰明選擇', 'お元気ですか?', '全國電子 足感心ㄟ', '全家就是你家', '再忙,也要和你喝杯咖啡', '別讓今天的應酬成為明天的負擔', '到服裝店培養氣質,到書店展示服裝', '化去心中那條線', '原來我們這麼近', '只有遠傳,沒有距離', '只要有夢,你會紅', '叫天天不印 Canon幫你印!', '可憐的舊情人,看不到我的新內衣', '台灣,加油!', '合味才會呷意', '啊!福氣啦!', '喜歡嗎? 爸爸買給你!', '嚕加嚕好呷', '回家的感覺真好', '因為你值得 L’ORE’AL', '夏天好熱 愛要趁熱', '多喝水沒事,沒事多喝水', '夜深了,打個電話回家', '天生超人氣,不該遭人棄', '女人說好,才算頂好', '好東西和好朋友分享', '好的開喜就是成功的一半!', '好身體,沒人敢惹你', '好險,有南山!', '孩子!我要你將來比我強!', '學琴的孩子不會變壞', '安全是回家唯一的路', '小而美、小而冷、小而省', '幸福怎能說不用', '心,是人生最大的戰場', '您真內行!', '想像力是你的超能力', '慈母心、豆腐心', '我不認識你,但是我謝謝你!', '我就是超愛 Send!', '我的八分新摺學!', '拍誰像誰,誰拍誰誰都得像誰', '挺立,不只挺阮 也挺恁', '捐血一袋,救人一命', '撼動天下的力量', '擋不住的感覺', '整個城市就是我的咖啡館', '最佳女主角換你做做看', '有心最要緊', '有書才會贏', '有青才敢大聲', '有點黏又不會太黏', '期待下一次,不如靠自己', '未來 就是現在', '正反,反正都很正!', '每一句話,都是思念', '沒說出口的 保誠也聽得懂', '現在的Nobody,未來的Somebody!', '生命就該浪費在美好的事物上', '用你想要的方式道別', '用大金,省大金', '用好心腸做好香腸', '用愛打敗不景氣', '用最愛 照顧最愛', '留一盞燈給最後回家的人', '百服寧、保護您', '真感情就是最好的服務', '知識使你更有魅力', '碼碼都有獎', '管他什麼垢,一瓶就夠', '紅利點數也能當飯吃', '紙有春風最溫柔', '紙要Double A 萬事都OK!', '給你好看', '給我小心點兒', '肝哪沒好,人生是黑白的!肝哪顧好,人生是彩色的!', '肝苦誰人知', '萬事皆可達,唯有情無價', '認真的女人最美麗', '贏甲嘸知人', '路,是ESCAPE走出來的', '這不是肯德基!', '這個月不會來,下個月也不會來了,以後都不會來了', '這是一定要的啦!', '這種時機,無閒也是一種幸福', '這種鬼地方都收得到', '通往成功的路,總是在施工中', '鑽石恆久遠,一顆永留傳', '關心自己,也關心別人', '關機是一種美德', '陪妳Shopping 一輩子', '雅芳比女人更瞭解女人', '青菜底呷啦', '靜得讓您耳根清靜', '馬上就會好']
Tags
see
https://zh-tw.facebook.com/notes/%E7%8E%A9%E5%BB%A3%E5%91%8Aplaying-with-advertising/%E5%9B%9E%E9%A1%A7%E8%87%BA%E7%81%A3%E6%AD%B7%E5%B1%86%E5%BB%A3%E5%91%8A%E9%87%91%E5%8F%A5%E7%8D%8E/294008963985215

$companyEnFormats

protected static mixed $companyEnFormats = ['{{lastNameEn}} {{companyEnSuffix}}', '{{lastNameEn}}-{{lastNameEn}}', '{{lastNameEn}}, {{lastNameEn}} and {{lastNameEn}}']

$companyEnSuffix

protected static mixed $companyEnSuffix = ['Inc', 'and Sons', 'LLC', 'Group', 'PLC', 'Ltd']

$companyModifier

protected static mixed $companyModifier = ['科技', '電腦', '國際', '電子', '娛樂', '音樂', '唱片', '證券', '集團', '企業', '機械', '工業', '文化', '汽車', '百貨', '酒店', '數位']

$companyPrefix

protected static mixed $companyPrefix = ['乾坤', '亞神', '光譜', '典選', '凱基', '前衛花園', '創見', '友訊', '台達', '合勤', '喜瑪拉雅', '喬山', '多利安', '大國', '大宇', '太陽', '太陽動力', '宏碁', '宏達', '小白兔', '巨大', '巨室', '康師傅', '延伸', '弘煜', '彎的', '擎天', '新亞洲', '旺旺', '昱泉', '智冠', '未來', '松崗', '正新', '洧誠', '海蝶', '添翼創越', '滾石', '王品', '當然', '相信', '睛水', '研華', '福茂', '種子', '米樂士', '紅元素', '紅心辣椒', '統一', '美利達', '美妙', '美樂帝', '群石', '老鷹', '聯強', '芮河', '英特衛', '茂為', '華特', '華研', '華碩', '華義', '角頭', '訊連', '豐華', '豪客', '豪記', '貴族', '趨勢', '遊戲橘子', '野火樂集', '金革', '銀魚', '阿爾發', '風和日麗', '風潮', '風雲']
Tags
see
http://zh.wikipedia.org/zh-tw/Category:%E5%8F%B0%E7%81%A3%E5%85%AC%E5%8F%B8%E5%88%97%E8%A1%A8

$companySuffix

protected static mixed $companySuffix = ['公司', '有限公司', '股份有限公司']

$formats

protected static mixed $formats = ['{{companyPrefix}}{{companyModifier}}', '{{companyPrefix}}{{companySuffix}}', '{{companyPrefix}}{{companyModifier}}{{CompanySuffix}}']

$jobTitleFormat

protected static mixed $jobTitleFormat = ['{{word}}']

Methods

__construct()

public __construct(Generator $generator) : mixed
Parameters
$generator : Generator
Return values
mixed

asciify()

Replaces * signs with random numbers and letters and special characters

public static asciify([string $string = '****' ]) : string
Parameters
$string : string = '****'

String that needs to bet parsed

Tags
example

$faker->asciify(''********'); // "s5'G!uC3"

Return values
string

bothify()

Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter

public static bothify([string $string = '## ??' ]) : string
Parameters
$string : string = '## ??'

String that needs to bet parsed

Return values
string

bs()

public bs() : mixed
Return values
mixed

catchPhrase()

public catchPhrase() : mixed
Return values
mixed

company()

public company() : string
Tags
example

'Acme Ltd'

Return values
string

companyEn()

public companyEn() : mixed
Return values
mixed

companyEnSuffix()

public static companyEnSuffix() : mixed
Return values
mixed

companyModifier()

public static companyModifier() : mixed
Return values
mixed

companyPrefix()

public static companyPrefix() : mixed
Return values
mixed

companySuffix()

public static companySuffix() : string
Tags
example

'Ltd'

Return values
string

jobTitle()

public jobTitle() : string
Tags
example

'Job'

Return values
string

lexify()

Replaces all question mark ('?') occurrences with a random letter

public static lexify([string $string = '????' ]) : string
Parameters
$string : string = '????'

String that needs to bet parsed

Return values
string

numberBetween()

Returns a random number between $int1 and $int2 (any order)

public static numberBetween(int $int1[, int $int2 = 2147483647 ]) : int
Parameters
$int1 : int

default to 0

$int2 : int = 2147483647

defaults to 32 bit max integer, ie 2147483647

Tags
example

79907610

Return values
int

numerify()

Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number

public static numerify([string $string = '###' ]) : string
Parameters
$string : string = '###'

String that needs to bet parsed

Return values
string

optional()

Chainable method for making any formatter optional.

public optional([float|int $weight = 0.5 ][, mixed $default = null ]) : mixed|null
Parameters
$weight : float|int = 0.5

Set the probability of receiving a null value. "0" will always return null, "1" will always return the generator. If $weight is an integer value, then the same system works between 0 (always get false) and 100 (always get true).

$default : mixed = null
Return values
mixed|null

passthrough()

Returns the passed value

public static passthrough(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

randomAscii()

Returns a random ASCII character (excluding accents and special chars)

public static randomAscii() : string
Return values
string

randomDigit()

Returns a random number between 0 and 9

public static randomDigit() : int
Return values
int

randomDigitNot()

Generates a random digit, which cannot be $except

public static randomDigitNot(int $except) : int
Parameters
$except : int
Return values
int

randomDigitNotNull()

Returns a random number between 1 and 9

public static randomDigitNotNull() : int
Return values
int

randomElement()

Returns a random element from a passed array

public static randomElement([array<string|int, mixed> $array = ['a', 'b', 'c'] ]) : mixed
Parameters
$array : array<string|int, mixed> = ['a', 'b', 'c']
Return values
mixed

randomElements()

Returns randomly ordered subsequence of $count elements from a provided array

public static randomElements([array<string|int, mixed> $array = ['a', 'b', 'c'] ][, int $count = 1 ][, bool $allowDuplicates = false ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed> = ['a', 'b', 'c']

Array to take elements from. Defaults to a-c

$count : int = 1

Number of elements to take.

$allowDuplicates : bool = false

Allow elements to be picked several times. Defaults to false

Tags
throws
LengthException

When requesting more elements than provided

Return values
array<string|int, mixed>

New array with $count elements from $array

randomFloat()

Return a random float number

public static randomFloat([int $nbMaxDecimals = null ], float|int $min[, float|int $max = null ]) : float
Parameters
$nbMaxDecimals : int = null
$min : float|int
$max : float|int = null
Tags
example

48.8932

Return values
float

randomKey()

Returns a random key from a passed associative array

public static randomKey([array<string|int, mixed> $array = [] ]) : int|string|null
Parameters
$array : array<string|int, mixed> = []
Return values
int|string|null

randomLetter()

Returns a random letter from a to z

public static randomLetter() : string
Return values
string

randomNumber()

Returns a random integer with 0 to $nbDigits digits.

public static randomNumber([int $nbDigits = null ][, bool $strict = false ]) : int

The maximum value returned is mt_getrandmax()

Parameters
$nbDigits : int = null

Defaults to a random number between 1 and 9

$strict : bool = false

Whether the returned number should have exactly $nbDigits

Tags
example

79907610

Return values
int

regexify()

Transforms a basic regular expression into a random string satisfying the expression.

public static regexify([string $regex = '' ]) : string
Parameters
$regex : string = ''

A regular expression (delimiters are optional)

Tags
example

$faker->regexify('[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}'); // sm0@y8k96a.ej

Regex delimiters '/.../' and begin/end markers '^...$' are ignored.

Only supports a small subset of the regex syntax. For instance, unicode, negated classes, unbounded ranges, subpatterns, back references, assertions, recursive patterns, and comments are not supported. Escaping support is extremely fragile.

This method is also VERY slow. Use it only when no other formatter can generate the fake data you want. For instance, prefer calling $faker->email rather than regexify with the previous regular expression.

Also note than bothify can probably do most of what this method does, but much faster. For instance, for a dummy email generation, try $faker->bothify('?????????@???.???').

see
https://github.com/icomefromthenet/ReverseRegex

for a more robust implementation

Return values
string

shuffle()

Returns a shuffled version of the argument.

public static shuffle([array<string|int, mixed>|string $arg = '' ]) : array<string|int, mixed>|string

This function accepts either an array, or a string.

Parameters
$arg : array<string|int, mixed>|string = ''

The set to shuffle

Tags
example

$faker->shuffle([1, 2, 3]); // [2, 1, 3]

example

$faker->shuffle('hello, world'); // 'rlo,h eold!lw'

see
shuffleArray()
see
shuffleString()
Return values
array<string|int, mixed>|string

The shuffled set

shuffleArray()

Returns a shuffled version of the array.

public static shuffleArray([array<string|int, mixed> $array = [] ]) : array<string|int, mixed>

This function does not mutate the original array. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable.

Parameters
$array : array<string|int, mixed> = []

The set to shuffle

Tags
see
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
example

$faker->shuffleArray([1, 2, 3]); // [2, 1, 3]

Return values
array<string|int, mixed>

The shuffled set

shuffleString()

Returns a shuffled version of the string.

public static shuffleString([string $string = '' ][, string $encoding = 'UTF-8' ]) : string

This function does not mutate the original string. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable. Additionally, it is UTF8 safe if the mb extension is available.

Parameters
$string : string = ''

The set to shuffle

$encoding : string = 'UTF-8'

The string encoding (defaults to UTF-8)

Tags
see
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
example

$faker->shuffleString('hello, world'); // 'rlo,h eold!lw'

Return values
string

The shuffled set

toLower()

Converts string to lowercase.

public static toLower([string $string = '' ]) : string

Uses mb_string extension if available.

Parameters
$string : string = ''

String that should be converted to lowercase

Return values
string

toUpper()

Converts string to uppercase.

public static toUpper([string $string = '' ]) : string

Uses mb_string extension if available.

Parameters
$string : string = ''

String that should be converted to uppercase

Return values
string

unique()

Chainable method for making any formatter unique.

public unique([bool $reset = false ][, int $maxRetries = 10000 ]) : UniqueGenerator
// will never return twice the same value $faker->unique()->randomElement(array(1, 2, 3));
Parameters
$reset : bool = false

If set to true, resets the list of existing values

$maxRetries : int = 10000

Maximum number of retries to find a unique value, After which an OverflowException is thrown.

Tags
throws
OverflowException

When no unique value can be found by iterating $maxRetries times

Return values
UniqueGenerator

A proxy class returning only non-existing values

valid()

Chainable method for forcing any formatter to return only valid values.

public valid([Closure $validator = null ][, int $maxRetries = 10000 ]) : ValidGenerator

The value validity is determined by a function passed as first argument.

$values = array(); $evenValidator = function ($digit) { return $digit % 2 === 0; }; for ($i=0; $i < 10; $i++) { $values []= $faker->valid($evenValidator)->randomDigit; } print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]
Parameters
$validator : Closure = null

A function returning true for valid values

$maxRetries : int = 10000

Maximum number of retries to find a unique value, After which an OverflowException is thrown.

Tags
throws
OverflowException

When no valid value can be found by iterating $maxRetries times

Return values
ValidGenerator

A proxy class returning only valid values

VAT()

return standard VAT / Tax ID / Uniform Serial Number

public VAT() : int
Tags
example

28263822

Return values
int

replaceWildcard()

private static replaceWildcard(mixed $string[, mixed $wildcard = '#' ][, mixed $callback = 'static::randomDigit' ]) : mixed
Parameters
$string : mixed
$wildcard : mixed = '#'
$callback : mixed = 'static::randomDigit'
Return values
mixed

Search results