1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-01-17 22:28:55 +01:00

Update example to the latest text() capabilities

This commit is contained in:
Francois Zaninotto 2011-10-16 23:06:54 +02:00
parent 459123a8f3
commit 06f934bd0a
2 changed files with 174 additions and 184 deletions

351
readme.md
View File

@ -55,84 +55,84 @@ for ($i=0; $i < 10; $i++) {
Each of the generator properties (like `name`, `address`, and `lorem`) are called "formatters". A faker generator has many of them, packaged in "providers". Here is a list of the bundled formatters in the default locale.
### `Faker\Provider\DateTime`
### `Faker\Provider\en_US\Name`
amPm // 'am'
century // 'V'
date($format = 'Y-m-d') // '2008-11-27'
dateTime // 2005-08-16 20:58:39
dateTimeBetween($startDate = '-30 years', $endDate = 'now') // 1999-02-02 12:05:31
dateTimeThisCentury // 1964-04-04 11:24:41
dateTimeThisDecade // 2010-03-10 05:41:37
dateTimeThisMonth // 2011-10-05 13:14:25
dateTimeThisYear // 2011-09-19 09:47:16
dayOfMonth // '29'
dayOfWeek // 'Thursday'
iso8601 // '2003-10-21T16:24:11+0000'
month // '06'
monthName // 'November'
time($format = 'H:i:s') // '15:17:03'
unixTime // 1061307820
year // '1991'
### `Faker\Provider\Internet`
domainName // 'mueller.info'
domainWord // 'von'
email // 'cshields@rosenbaum.com'
freeEmail // 'dayna55@gmail.com'
freeEmailDomain // 'yahoo.com'
ipv4 // '237.149.115.38'
ipv6 // '35cd:186d:3e23:2986:ef9f:5b41:42a4:e6f1'
safeEmail // 'nbatz@example.org'
tld // 'info'
url // 'http://www.runolfsdottir.com/'
userName // 'tremblay.haylie'
### `Faker\Provider\Lorem`
lorem($nbParagraphs = 3) // 'Fuga totam reiciendis qui architecto fugiat. (...)'
paragraph($nbSentences = 3) // 'Sed a nam et sint autem. Aut officia aut. Blanditiis et ducimus.'
paragraphs($nb = 3) // array('Amet et est. (...)', 'Sequi cum culpa rem. Rerum exercitationem est.')
sentence($nbWords = 3) // 'Sit vitae voluptas sint non.'
sentences($nb = 3) // array('Ut optio quos qui illo error nihil.', 'Vero a officia id corporis incidunt.', 'Provident esse hic eligendi quos culpa ut.')
word // 'aut'
words($nb = 3) // array('porro', 'sed', 'magni')
prefix // 'Ms.'
suffix // 'Jr.'
name // 'Dr. Zane Stroman'
firstName // 'Maynard'
lastName // 'Zulauf'
### `Faker\Provider\en_US\Address`
address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473'
buildingNumber // '484'
city // 'West Judge'
cityPrefix // 'Lake'
citySuffix // 'borough'
country // 'Falkland Islands (Malvinas)'
postcode // '17916'
secondaryAddress // 'Suite 961'
state // 'NewMexico'
stateAbbr // 'OH'
streetAddress // '439 Karley Loaf Suite 897'
streetName // 'Keegan Trail'
citySuffix // 'borough'
streetSuffix // 'Keys'
### `Faker\Provider\en_US\Company`
bs // 'e-enable robust architectures'
catchPhrase // 'Monitored regional contingency'
company // 'Bogan-Treutel'
companySuffix // 'and Sons'
### `Faker\Provider\en_US\Name`
firstName // 'Maynard'
lastName // 'Zulauf'
name // 'Dr. Zane Stroman'
prefix // 'Ms.'
suffix // 'Jr.'
buildingNumber // '484'
city // 'West Judge'
streetName // 'Keegan Trail'
streetAddress // '439 Karley Loaf Suite 897'
postcode // '17916'
address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473'
country // 'Falkland Islands (Malvinas)'
### `Faker\Provider\en_US\PhoneNumber`
phoneNumber // '132-149-0269x3767'
phoneNumber // '132-149-0269x3767'
### `Faker\Provider\en_US\Company`
catchPhrase // 'Monitored regional contingency'
bs // 'e-enable robust architectures'
company // 'Bogan-Treutel'
companySuffix // 'and Sons'
### `Faker\Provider\Lorem`
word // 'aut'
words($nb = 3) // array('porro', 'sed', 'magni')
sentence($nbWords = 6) // 'Sit vitae voluptas sint non voluptates.'
sentences($nb = 3) // array('Optio quos qui illo error.', 'Laborum vero a officia id corporis.', 'Saepe provident esse hic eligendi.')
paragraph($nbSentences = 3) // 'Ut ab voluptas sed a nam. Sint autem inventore aut officia aut aut blanditiis. Ducimus eos odit amet et est ut eum.'
paragraphs($nb = 3) // array('Quidem ut sunt et quidem est accusamus aut. Fuga est placeat rerum ut. Enim ex eveniet facere sunt.', 'Aut nam et eum architecto fugit repellendus illo. Qui ex esse veritatis.', 'Possimus omnis aut incidunt sunt. Asperiores incidunt iure sequi cum culpa rem. Rerum exercitationem est rem.')
text($maxNbChars = 200) // 'Fuga totam reiciendis qui architecto fugiat nemo. Consequatur recusandae qui cupiditate eos quod.'
### `Faker\Provider\Internet`
email // 'tkshlerin@collins.com'
safeEmail // 'king.alford@example.org'
freeEmail // 'bradley72@gmail.com'
freeEmailDomain // 'yahoo.com'
userName // 'wade55'
domainName // 'wolffdeckow.net'
domainWord // 'feeney'
tld // 'biz'
url // 'http://www.strackeframi.com/'
ipv4 // '109.133.32.252'
ipv6 // '8e65:933d:22ee:a232:f1c1:2741:1f10:117c'
### `Faker\Provider\DateTime`
unixTime // 58754961
dateTime // 2008-04-18 23:11:35
iso8601 // '2007-05-25T12:25:57+0000'
date($format = 'Y-m-d') // '1978-12-07'
time($format = 'H:i:s') // '04:46:58'
dateTimeBetween($startDate = '-30 years', $endDate = 'now') // 2000-04-13 00:11:22
dateTimeThisCentury // 1983-02-02 19:44:03
dateTimeThisDecade // 2002-02-25 08:17:41
dateTimeThisYear // 2011-05-09 04:08:14
dateTimeThisMonth // 2011-09-27 07:34:20
amPm // 'pm'
dayOfMonth // '04'
dayOfWeek // 'Wednesday'
month // '09'
monthName // 'June'
year // '1985'
century // 'XII'
## Localization
@ -190,8 +190,8 @@ $generator = Faker\Factory::create();
<?php for ($i=0; $i < 10; $i++): ?>
<contact firstName="<?php echo $generator->firstName ?>" lastName="<?php echo $generator->lastName ?>" email="<?php echo $generator->email ?>"/>
<phone number="<?php echo $generator->phoneNumber ?>"/>
<?php if (mt_rand(0,5) == 0): ?>
<countryOfBirth><?php echo $generator->address ?></countryOfBirth>
<?php if (mt_rand(0,3) == 0): ?>
<birth date="<?php echo $generator->dateTimeThisCentury->format('Y-m-d') ?>" place="<?php echo $generator->city ?>"/>
<?php endif; ?>
<address>
<street><?php echo $generator->streetAddress ?></street>
@ -210,7 +210,7 @@ $generator = Faker\Factory::create();
<?php if (mt_rand(0,5) == 0): ?>
<details>
<![CDATA[
<?php echo $generator->lorem(3) ?>
<?php echo $generator->text(400) ?>
]]>
</details>
<?php endif; ?>
@ -224,146 +224,135 @@ Running this script produces a document looking like:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<contacts>
<contact firstName="Celestino" lastName="Gottlieb" email="katlyn35@hilll.com"/>
<phone number="03923563989"/>
<contact firstName="Ona" lastName="Bednar" email="schamberger.frank@wuckert.com"/>
<phone number="1-265-479-1196x714"/>
<address>
<street>39640 Alize Radial</street>
<city>North Robbburgh</city>
<postcode>06688-4406</postcode>
<street>182 Harrison Cove</street>
<city>North Lloyd</city>
<postcode>45577</postcode>
<state>Alabama</state>
</address>
<company name="Veum, Funk and Shanahan" catchPhrase="Function-based stable solution">
<offer>orchestrate compelling web-readiness</offer>
</company>
<details>
<![CDATA[
Alias accusantium voluptatum autem nobis cumque neque modi. Voluptatem error molestiae consequatur alias.
Illum commodi molestiae aut repellat id. Et sit consequuntur aut et ullam asperiores. Cupiditate culpa voluptatem et mollitia dolor. Nisi praesentium qui ut.
]]>
</details>
</contact>
<contact firstName="Aurelie" lastName="Paucek" email="alfonzo55@durgan.com"/>
<phone number="863.712.1363x9425"/>
<address>
<street>90111 Hegmann Inlet</street>
<city>South Geovanymouth</city>
<postcode>69961-9311</postcode>
<state>Colorado</state>
</address>
<company name="Johnston, Eichmann and Hoppe" catchPhrase="Compatible regional leverage">
<offer>e-enable bleeding-edge interfaces</offer>
<director name="Ms. Elton Walsh" />
<company name="Krajcik-Grimes" catchPhrase="Switchable cohesive instructionset">
</company>
</contact>
<contact firstName="Gladyce" lastName="Fritsch" email="nicola77@moore.com"/>
<phone number="+21(1)6349842909"/>
<contact firstName="Clifton" lastName="Kshlerin" email="kianna.wiegand@framiwyman.info"/>
<phone number="692-194-4746"/>
<address>
<street>973 Bruen Lock Suite 302</street>
<city>Konopelskimouth</city>
<postcode>11578-6604</postcode>
<state>Nebraska</state>
<street>9791 Nona Corner</street>
<city>Harberhaven</city>
<postcode>74062-8191</postcode>
<state>RhodeIsland</state>
</address>
<company name="Volkman, Bergnaum and Kub" catchPhrase="Secured intangible firmware">
<company name="Rosenbaum-Aufderhar" catchPhrase="Realigned asynchronous encryption">
</company>
</contact>
<contact firstName="Alexandre" lastName="Orn" email="thelma37@erdmancorwin.biz"/>
<phone number="189.655.8677x027"/>
<address>
<street>11161 Schultz Via</street>
<city>Feilstad</city>
<postcode>98019</postcode>
<state>NewJersey</state>
</address>
<company name="O'Hara-Prosacco" catchPhrase="Re-engineered solution-oriented algorithm">
<director name="Dr. Berenice Auer V" />
</company>
<details>
<![CDATA[
Et eum voluptatibus dolorum possimus aut beatae. Nam voluptatem maiores reiciendis blanditiis fuga. Eum laborum et voluptate. Architecto quia similique autem consequatur.
Ex nostrum quos. Et adipisci at quod iure quas. Ipsa totam ut dignissimos. Consectetur corrupti quaerat et expedita numquam nesciunt. Recusandae sunt dolor itaque reprehenderit hic. Sunt quibusdam consequatur atque consequatur eos.
Explicabo inventore debitis. Iste ea quidem. Accusantium eum velit aut ab repudiandae voluptate. Dicta aut sit id fuga maxime ea. Aut ex perferendis nisi autem. Voluptas praesentium odio.
Perferendis optio sit possimus voluptate provident sunt. Et temporibus dolores nemo provident neque ut. Natus facilis deleniti alias quam odio.
Voluptatem et dolorum natus tenetur doloremque. Necessitatibus distinctio architecto et natus fuga repudiandae. Rerum natus minus eos.
Autem porro doloribus. Nam non officiis vero vitae autem. Ad nihil unde facere. Aliquam deleniti nesciunt eligendi. Harum accusamus sed consectetur nisi.
Ut itaque et quaerat doloremque eum praesentium. Rerum in saepe dolorem. Explicabo qui consequuntur commodi minima rem.
Harum temporibus rerum dolores. Non molestiae id dolorem placeat.
Aut asperiores nihil eius repellendus. Vero nihil corporis voluptatem explicabo commodi. Occaecati omnis blanditiis beatae quod aspernatur eos.
]]>
</details>
</contact>
<contact firstName="Rick" lastName="Emard" email="schulist.branson@mckenzie.net"/>
<phone number="135.692.0747x21203"/>
<contact firstName="Katelynn" lastName="Kohler" email="reinger.trudie@stiedemannjakubowski.com"/>
<phone number="(665)713-1657"/>
<address>
<street>1715 King Island Suite 086</street>
<city>Schmittside</city>
<postcode>03005-2057</postcode>
<state>Colorado</state>
<street>6106 Nader Village Suite 753</street>
<city>McLaughlinstad</city>
<postcode>43189-8621</postcode>
<state>Missouri</state>
</address>
<company name="Willms-Hessel" catchPhrase="Progressive neutral pricingstructure">
<company name="Herman-Tremblay" catchPhrase="Object-based explicit service-desk">
<offer>expedite viral synergies</offer>
<director name="Arden Deckow" />
</company>
</contact>
<contact firstName="Thad" lastName="Windler" email="will99@brown.info"/>
<phone number="1-150-356-8950x9389"/>
<contact firstName="Blanca" lastName="Stark" email="tad27@feest.net"/>
<phone number="168.719.4692x87177"/>
<address>
<street>455 Mitchell Harbor Suite 177</street>
<city>South Alfordville</city>
<postcode>09848-8284</postcode>
<state>Idaho</state>
<street>7546 Kuvalis Plaza</street>
<city>South Wilfrid</city>
<postcode>77069</postcode>
<state>Georgia</state>
</address>
<company name="Erdman and Sons" catchPhrase="Operative multi-state encoding">
<company name="Upton, Braun and Rowe" catchPhrase="Visionary leadingedge pricingstructure">
</company>
</contact>
<contact firstName="Irma" lastName="Schneider" email="ykeeling@jenkins.net"/>
<phone number="1-623-377-9667"/>
<contact firstName="Rene" lastName="Spencer" email="anibal28@armstrong.info"/>
<phone number="715.222.0095x175"/>
<birth date="2008-07-25" place="Zulaufborough"/>
<address>
<street>5024 Kulas Cliffs</street>
<city>West Carter</city>
<postcode>24046</postcode>
<state>SouthCarolina</state>
</address>
<company name="Armstrong, Hoeger and Goodwin" catchPhrase="Quality-focused bottom-line access">
<director name="Miss Neha Stanton" />
</company>
</contact>
<contact firstName="Ellis" lastName="Wolff" email="ebert.myron@schuster.biz"/>
<phone number="(990)523-4464x553"/>
<address>
<street>4313 Edmond Lights</street>
<city>North Elenahaven</city>
<postcode>40625</postcode>
<state>Maryland</state>
</address>
<company name="Crist LLC" catchPhrase="Realigned homogeneous GraphicInterface">
<director name="Jayce Schroeder" />
</company>
<details>
<![CDATA[
Impedit aut rerum praesentium consequatur. Non ut ducimus vel quia impedit ipsa. Explicabo quasi eius et. Sed numquam illo dolores debitis delectus.
Nisi dolore corporis cumque aut enim. Et modi fuga dicta. Quo rem voluptatem. Nulla consequatur vel aut expedita quae.
Rerum sunt qui voluptatem dicta facilis. Rerum maiores omnis repellat. Dolor sed quia rerum qui qui. Accusantium eos ipsa repellendus velit voluptatem asperiores. Et et amet sit in. Explicabo voluptas ut.
Dignissimos porro autem veniam quo aut. Eos perspiciatis rerum magnam adipisci. Ratione quas modi. Ea quia delectus rem dolores. Ea commodi hic.
Fuga quia et facilis nemo voluptate aliquam. Dignissimos aut qui ipsum. Provident distinctio rerum omnis et enim. Qui odit dicta. Soluta distinctio dolorum molestiae sunt ipsa. Nesciunt quaerat beatae exercitationem dolores facere hic.
Dolorem consequuntur repellendus suscipit. Et dolorem consequuntur sint doloremque repellat ad. Impedit reiciendis asperiores. Quod aspernatur nesciunt facere. Nisi minus asperiores ex sed et. Fugiat alias repellendus distinctio nesciunt.
]]>
</details>
</contact>
<contact firstName="Stanton" lastName="Bruen" email="pacocha.avis@buckridgedavis.com"/>
<phone number="1-180-800-6214x0417"/>
<address>
<street>6277 Bruen Pass</street>
<city>New Emeliaport</city>
<postcode>55131-3794</postcode>
<state>Arkansas</state>
</address>
<company name="Shanahan-Mitchell" catchPhrase="Secured grid-enabled throughput">
</company>
</contact>
<contact firstName="Amalia" lastName="Dietrich" email="romaguera.fatima@bogisich.com"/>
<phone number="250.571.3328"/>
<address>
<street>9900 Wellington Center</street>
<city>Irvingbury</city>
<postcode>58271</postcode>
<state>Nevada</state>
</address>
<company name="Purdy, Paucek and Hintz" catchPhrase="Ergonomic tertiary data-warehouse">
</company>
<details>
<![CDATA[
Voluptas doloremque asperiores. Quaerat iste quia suscipit consectetur. Consectetur placeat rem distinctio numquam.
Ab debitis odio neque. Repellat autem ea quas sequi exercitationem. Tempore omnis totam optio consectetur perferendis. Consectetur saepe voluptatem dolorem quae.
Sed aliquid labore alias libero vitae amet. Asperiores accusantium quidem nihil amet necessitatibus rerum. Aut inventore cupiditate quisquam voluptatibus nesciunt. In sunt quam.
At quis fugiat ut possimus debitis eos. Labore ipsum veniam. Aliquid consequatur voluptatem fugiat deserunt. Natus non voluptatum nam minima. Eveniet libero incidunt dolores iure deleniti. Dolorem deserunt aliquam eius commodi odio.
]]>
</details>
</contact>
<contact firstName="Laurine" lastName="Prohaska" email="dovie53@jenkinsokuneva.info"/>
<phone number="502.295.9840x98725"/>
<address>
<street>07633 Ryann Throughway</street>
<city>Hicklefurt</city>
<postcode>97260</postcode>
<street>478 Daisha Landing Apt. 510</street>
<city>West Lizethhaven</city>
<postcode>30566-5362</postcode>
<state>WestVirginia</state>
</address>
<company name="Hermiston LLC" catchPhrase="Inverse bi-directional projection">
<company name="Wiza Inc" catchPhrase="Persevering reciprocal approach">
<director name="Roel DuBuque" />
</company>
</contact>
<contact firstName="Brett" lastName="Lehner" email="tdooley@weber.com"/>
<phone number="251.924.8740x80198"/>
<contact firstName="Erwin" lastName="Nienow" email="hudson88@lockman.com"/>
<phone number="+87(6)0704857083"/>
<birth date="2009-02-11" place="Estrellaside"/>
<address>
<street>53265 Abernathy Lock</street>
<city>South Rosettastad</city>
<postcode>85744</postcode>
<state>Oklahoma</state>
<street>0920 Adah Skyway</street>
<city>South Kristopher</city>
<postcode>62693</postcode>
<state>Mississippi</state>
</address>
<company name="Monahan LLC" catchPhrase="Operative analyzing middleware">
<company name="Jakubowski Inc" catchPhrase="Secured object-oriented conglomeration">
</company>
</contact>
<contact firstName="Zoie" lastName="Murazik" email="zschuster@hartmann.org"/>
<phone number="(179)927-3745"/>
<address>
<street>91758 Sienna Burg Apt. 791</street>
<city>Murrayfurt</city>
<postcode>44284</postcode>
<state>Virginia</state>
</address>
<company name="Schmitt-Moore" catchPhrase="Robust modular software">
<director name="Brianne Fahey" />
</company>
</contact>
<contact firstName="Claud" lastName="Rosenbaum" email="adelbert08@barrowsshields.com"/>
<phone number="203.581.7085x587"/>
<address>
<street>165 Bogisich Unions Apt. 630</street>
<city>Corwinhaven</city>
<postcode>57971</postcode>
<state>Virginia</state>
</address>
<company name="Mann, Price and Hartmann" catchPhrase="Versatile mobile securedline">
</company>
</contact>
</contacts>

View File

@ -1,14 +1,15 @@
<?php
require_once __DIR__ . '/../src/Factory.php';
$generator = Faker\Factory::create();
$generator->seed(5);
?>
<?xml version="1.0" encoding="UTF-8"?>
<contacts>
<?php for ($i=0; $i < 10; $i++): ?>
<contact firstName="<?php echo $generator->firstName ?>" lastName="<?php echo $generator->lastName ?>" email="<?php echo $generator->email ?>"/>
<phone number="<?php echo $generator->phoneNumber ?>"/>
<?php if (mt_rand(0,5) == 0): ?>
<countryOfBirth><?php echo $generator->address ?></countryOfBirth>
<?php if (mt_rand(0,3) == 0): ?>
<birth date="<?php echo $generator->dateTimeThisCentury->format('Y-m-d') ?>" place="<?php echo $generator->city ?>"/>
<?php endif; ?>
<address>
<street><?php echo $generator->streetAddress ?></street>
@ -27,7 +28,7 @@ $generator = Faker\Factory::create();
<?php if (mt_rand(0,5) == 0): ?>
<details>
<![CDATA[
<?php echo $generator->lorem(3) ?>
<?php echo $generator->text(400) ?>
]]>
</details>
<?php endif; ?>