Permalink
Browse files

initial commit.

  • Loading branch information...
0 parents commit 74cfeb48a4441b3b0f21603f4d2d310590a95087 @bobthecow bobthecow committed Jul 28, 2011
Showing with 1,125 additions and 0 deletions.
  1. +19 −0 LICENSE
  2. +80 −0 README.markdown
  3. +184 −0 src/Faker/Address.php
  4. +138 −0 src/Faker/Company.php
  5. +102 −0 src/Faker/DateTime.php
  6. +35 −0 src/Faker/Faker.php
  7. +72 −0 src/Faker/Internet.php
  8. +75 −0 src/Faker/Lorem.php
  9. +394 −0 src/Faker/Name.php
  10. +26 −0 src/Faker/PhoneNumber.php
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Justin Hileman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,80 @@
+Faker
+=====
+
+[Faker][php] is a PHP port of [a Ruby port][ruby] of [`Data::Faker` from Perl][perl].
+
+It's a convoluted path, but you're the beneficiary of a simple way to generate fake
+data for your PHP 5.3 project.
+
+
+Usage is fairly straightforward:
+--------------------------------
+
+ echo \Faker\Name::name(); // "Leeroy Jenkins"
+
+
+There are a few more to choose from:
+------------------------------------
+
+ \Faker\Address::address();
+ \Faker\Address::streetName();
+ \Faker\Address::streetAddress($includeSecondary = false);
+ \Faker\Address::city();
+ \Faker\Address::state();
+ \Faker\Address::stateAbbr();
+ \Faker\Address::zipCode();
+ \Faker\Address::zip();
+ \Faker\Address::postcode();
+ \Faker\Address::cityStateZip();
+ \Faker\Address::country();
+
+ \Faker\Company::name();
+ \Faker\Company::suffix();
+ \Faker\Company::catchPhrase();
+ \Faker\Company::bs();
+
+ \Faker\DateTime::timestamp();
+ \Faker\DateTime::date($format = null);
+ \Faker\DateTime::dateFormat();
+ \Faker\DateTime::time($format = null);
+ \Faker\DateTime::timeFormat();
+ \Faker\DateTime::dateTime($format = null);
+ \Faker\DateTime::dateTimeFormat();
+ \Faker\DateTime::month();
+ \Faker\DateTime::monthAbbr();
+ \Faker\DateTime::weekday();
+ \Faker\DateTime::weekdayAbbr();
+
+ \Faker\Internet::email($name = null);
+ \Faker\Internet::freeEmail($name = null);
+ \Faker\Internet::userName($name = null);
+ \Faker\Internet::domainName();
+ \Faker\Internet::domainWord();
+ \Faker\Internet::domainSuffix();
+ \Faker\Internet::ipv4Address();
+
+ \Faker\Lorem::words($num = 3);
+ \Faker\Lorem::sentence($wordCount = 4);
+ \Faker\Lorem::sentences($sentenceCount = 3);
+ \Faker\Lorem::paragraph($sentenceCount = 3);
+ \Faker\Lorem::paragraphs($paragraphCount = 3);
+
+ \Faker\Name::name();
+ \Faker\Name::firstName();
+ \Faker\Name::lastName();
+ \Faker\Name::prefix();
+ \Faker\Name::suffix();
+
+ \Faker\PhoneNumber::phoneNumber();
+
+
+Yeah,
+-----
+
+... it's an entire library made up of static methods. Just to bug [Bulat][bulat] :)
+
+
+ [php]: http://github.com/bobthecow/Faker
+ [ruby]: http://faker.rubyforge.org/
+ [perl]: http://search.cpan.org/~jasonk/Data-Faker-0.07/lib/Data/Faker.pm
+ [bulat]: http://github.com/avalanche123
@@ -0,0 +1,184 @@
+<?php
+
+/*
+ * This file is part of the Faker package.
+ *
+ * (c) 2011 Justin Hileman
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Faker;
+
+abstract class Address extends Faker
+{
+ public static function address()
+ {
+ return implode("\n", array(self::streetAddress(rand(0, 1)), self::cityStateZip()));
+ }
+
+ public static function streetName()
+ {
+ return implode(' ', array(rand(0, 1) ? Name::firstName() : Name::lastName(), self::streetSuffix()));
+ }
+
+ public static function streetAddress($includeSecondary = false)
+ {
+ $chunks = array(
+ self::pickOne(array('#####', '####', '###')),
+ self::streetName(),
+ );
+
+ if ($includeSecondary) {
+ $chunks[] = self::secondaryAddress();
+ }
+
+ return self::numerify(implode(' ', $chunks));
+ }
+
+ private static function secondaryAddress()
+ {
+ return self::numerify(self::pickOne(array('Apt. ###', 'Suite ###')));
+ }
+
+ private static function streetSuffix()
+ {
+ return self::pickOne(array(
+ 'Alley', 'Avenue', 'Branch', 'Bridge', 'Brook', 'Brooks', 'Burg', 'Burgs', 'Bypass', 'Camp', 'Canyon',
+ 'Cape', 'Causeway', 'Center', 'Centers', 'Circle', 'Circles', 'Cliff', 'Cliffs', 'Club', 'Common', 'Corner',
+ 'Corners', 'Course', 'Court', 'Courts', 'Cove', 'Coves', 'Creek', 'Crescent', 'Crest', 'Crossing',
+ 'Crossroad', 'Curve', 'Dale', 'Dam', 'Divide', 'Drive', 'Drive', 'Drives', 'Estate', 'Estates',
+ 'Expressway', 'Extension', 'Extensions', 'Fall', 'Falls', 'Ferry', 'Field', 'Fields', 'Flat', 'Flats',
+ 'Ford', 'Fords', 'Forest', 'Forge', 'Forges', 'Fork', 'Forks', 'Fort', 'Freeway', 'Garden', 'Gardens',
+ 'Gateway', 'Glen', 'Glens', 'Green', 'Greens', 'Grove', 'Groves', 'Harbor', 'Harbors', 'Haven', 'Heights',
+ 'Highway', 'Hill', 'Hills', 'Hollow', 'Inlet', 'Inlet', 'Island', 'Island', 'Islands', 'Islands', 'Isle',
+ 'Isle', 'Junction', 'Junctions', 'Key', 'Keys', 'Knoll', 'Knolls', 'Lake', 'Lakes', 'Land', 'Landing',
+ 'Lane', 'Light', 'Lights', 'Loaf', 'Lock', 'Locks', 'Locks', 'Lodge', 'Lodge', 'Loop', 'Mall', 'Manor',
+ 'Manors', 'Meadow', 'Meadows', 'Mews', 'Mill', 'Mills', 'Mission', 'Mission', 'Motorway', 'Mount',
+ 'Mountain', 'Mountain', 'Mountains', 'Mountains', 'Neck', 'Orchard', 'Oval', 'Overpass', 'Park', 'Parks',
+ 'Parkway', 'Parkways', 'Pass', 'Passage', 'Path', 'Pike', 'Pine', 'Pines', 'Place', 'Plain', 'Plains',
+ 'Plains', 'Plaza', 'Plaza', 'Point', 'Points', 'Port', 'Port', 'Ports', 'Ports', 'Prairie', 'Prairie',
+ 'Radial', 'Ramp', 'Ranch', 'Rapid', 'Rapids', 'Rest', 'Ridge', 'Ridges', 'River', 'Road', 'Road', 'Roads',
+ 'Roads', 'Route', 'Row', 'Rue', 'Run', 'Shoal', 'Shoals', 'Shore', 'Shores', 'Skyway', 'Spring', 'Springs',
+ 'Springs', 'Spur', 'Spurs', 'Square', 'Square', 'Squares', 'Squares', 'Station', 'Station', 'Stravenue',
+ 'Stravenue', 'Stream', 'Stream', 'Street', 'Street', 'Streets', 'Summit', 'Summit', 'Terrace', 'Throughway',
+ 'Trace', 'Track', 'Trafficway', 'Trail', 'Trail', 'Tunnel', 'Tunnel', 'Turnpike', 'Turnpike', 'Underpass',
+ 'Union', 'Unions', 'Valley', 'Valleys', 'Via', 'Viaduct', 'View', 'Views', 'Village', 'Village', 'Villages',
+ 'Ville', 'Vista', 'Vista', 'Walk', 'Walks', 'Wall', 'Way', 'Ways', 'Well', 'Wells'
+ ));
+ }
+
+ public static function city()
+ {
+ return sprintf(
+ self::pickOne(array(
+ '%1$s %2$s%4$s',
+ '%1$s %2$s',
+ '%2$s%4$s',
+ '%3$s%4$s',
+ )),
+ self::cityPrefix(),
+ Name::firstName(),
+ Name::lastName(),
+ self::citySuffix()
+ );
+ }
+
+ private static function cityPrefix()
+ {
+ return self::pickOne(array('North', 'East', 'West', 'South', 'New', 'Lake', 'Port'));
+ }
+
+ private static function citySuffix()
+ {
+ return self::pickOne(array(
+ 'town', 'ton', 'land', 'ville', 'berg', 'burgh', 'borough', 'bury', 'view', 'port', 'mouth', 'stad', 'furt',
+ 'chester', 'mouth', 'fort', 'haven', 'side', 'shire'
+ ));
+ }
+
+ public static function state()
+ {
+ return self::pickOne(array(
+ 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida',
+ 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine',
+ 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska',
+ 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
+ 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota',
+ 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
+ ));
+ }
+
+ public static function stateAbbr()
+ {
+ return self::pickOne(array(
+ 'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN',
+ 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM',
+ 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI',
+ 'VA', 'WA', 'WV', 'WI', 'WY', 'AE', 'AA', 'AP'
+ ));
+ }
+
+ public static function zipCode()
+ {
+ return self::numerify(self::pickOne(array('#####', '#####-####')));
+ }
+
+ public static function zip()
+ {
+ return self::zipCode();
+ }
+
+ public static function postcode()
+ {
+ return self::zipCode();
+ }
+
+ public static function cityStateZip()
+ {
+ return sprintf('%s, %s %s', self::city(), self::state(), self::zipCode());
+ }
+
+ public static function country()
+ {
+ return self::pickOne(array(
+ 'Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla',
+ 'Antarctica (the territory South of 60 deg S)', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba',
+ 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium',
+ 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana',
+ 'Bouvet Island (Bouvetoya)', 'Brazil', 'British Indian Ocean Territory (Chagos Archipelago)',
+ 'British Virgin Islands', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia',
+ 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China',
+ 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Congo', 'Cook Islands',
+ 'Costa Rica', 'Cote d\'Ivoire', 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti',
+ 'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea',
+ 'Estonia', 'Ethiopia', 'Faroe Islands', 'Falkland Islands (Malvinas)', 'Fiji', 'Finland', 'France',
+ 'French Guiana', 'French Polynesia', 'French Southern Territories', 'Gabon', 'Gambia', 'Georgia', 'Germany',
+ 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey',
+ 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard Island and McDonald Islands',
+ 'Holy See (Vatican City State)', 'Honduras', 'Hong Kong', 'Hungary', 'Iceland', 'India', 'Indonesia',
+ 'Iran', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jersey', 'Jordan',
+ 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea', 'Korea', 'Kuwait', 'Kyrgyz Republic',
+ 'Lao People\'s Democratic Republic', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libyan Arab Jamahiriya',
+ 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macao', 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia',
+ 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte',
+ 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco',
+ 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands Antilles', 'Netherlands',
+ 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island',
+ 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palestinian Territory', 'Panama',
+ 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Pitcairn Islands', 'Poland', 'Portugal',
+ 'Puerto Rico', 'Qatar', 'Reunion', 'Romania', 'Russian Federation', 'Rwanda', 'Saint Barthelemy',
+ 'Saint Helena', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', 'Saint Pierre and Miquelon',
+ 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia',
+ 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia (Slovak Republic)', 'Slovenia',
+ 'Solomon Islands', 'Somalia', 'South Africa', 'South Georgia and the South Sandwich Islands', 'Spain',
+ 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard & Jan Mayen Islands', 'Swaziland', 'Sweden', 'Switzerland',
+ 'Syrian Arab Republic', 'Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste', 'Togo', 'Tokelau',
+ 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu',
+ 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States of America',
+ 'United States Minor Outlying Islands', 'United States Virgin Islands', 'Uruguay', 'Uzbekistan', 'Vanuatu',
+ 'Venezuela', 'Vietnam', 'Wallis and Futuna', 'Western Sahara', 'Yemen', 'Zambia', 'Zimbabwe'
+ ));
+ }
+}
Oops, something went wrong.

0 comments on commit 74cfeb4

Please sign in to comment.