Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.svn
64 changes: 64 additions & 0 deletions Faker.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

if (count(spl_autoload_functions()) <= 0)
{
require_once dirname(__FILE__) . '/autoload.php';
}

final class Faker
{

function __set ($property, $value)
{
throw new Exception('Unknow property "' . $property . '"');
}

private static $address;

public static function address ()
{
return self::$address ? self::$address : self::$address = new fkAddress();
}

private static $company;

public static function company ()
{
return self::$company ? self::$company : self::$company = new fkCompany();
}

private static $internet;

public static function internet ()
{
return self::$internet ? self::$internet : self::$internet = new fkInternet();
}

private static $lorem;

public static function lorem ()
{
return self::$lorem ? self::$lorem : self::$lorem = new fkLorem();
}

private static $name;

public static function name ()
{
return self::$name ? self::$name : self::$name = new fkName();
}

private static $phone;

public static function phoneNumber ()
{
return self::$phone ? self::$phone : self::$phone = new fkPhoneNumber();
}

private static $date;

public static function date ()
{
return self::$date ? self::$date : self::$date = new fkDate();
}
}
8 changes: 8 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

function fk_faker_autoload($class)
{
require_once dirname(__FILE__) . "/lib/$class.class.php";
}

spl_autoload_register('fk_faker_autoload');
135 changes: 0 additions & 135 deletions faker.php

This file was deleted.

117 changes: 58 additions & 59 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
<?php include 'faker.php'; ?><html>
<?php require_once 'Faker.class.php'; ?>
<html>
<head>
<title>Generating random data</title>
</head>
<body>

<?php
$arr = array(
'Name' => array(
'name' => array(
'name',
'first_name',
'firstName',
'surname',
'prefix',
'suffix',
),
'Address' => array(
'street_suffix',
'street_name',
'street_address',
'abode_address',
array( 'abode_address', true ),
'uk_county',
'uk_country',
'post_code',
'us_state',
'us_state_abbr',
'zip_code'
'address' => array(
'streetSuffix',
'streetName',
'streetAddress',
'abodeAddress',
array( 'abodeAddress', true ),
'ukCounty',
'ukCountry',
'postCode',
'usState',
'usStateAbbr',
'zipCode'
),
'Phone_Number' => array(
'phone_number'
'phoneNumber' => array(
'phoneNumber'
),
'Company' => array(
'company' => array(
'name',
'suffix',
'catch_phrase',
'catchPhrase',
'bs',
),
'Internet' => array(
'domain_suffix',
'domain_word',
'domain_name',
'user_name',
array( 'user_name', 'caius durling' ),
'internet' => array(
'domainSuffix',
'domainWord',
'domainName',
'userName',
array( 'userName', 'caius durling' ),
'email',
array( 'email', 'caius durling' ),
'free_email',
array( 'free_email', 'caius durling' ),
'freeEmail',
array( 'freeEmail', 'caius durling' ),
),
'Lorem' => array(
'lorem' => array(
'words',
'sentence',
'sentences',
Expand All @@ -57,41 +58,39 @@
?>

<table>
<legend>$f = new Faker</legend>
<legend>Faker::</legend>
<tr>
<th>PHP Statement</th>
<th>Output</th>
</tr>

<?php

$f = new Faker;

foreach ($arr as $class => $methods) {
foreach ($methods as $method) {
if ( is_array( $method ) ) {
?>
<tr>
<td>$f-><?php echo $class ?>-><?php echo $method[0] ?>( <?php echo $method[1] ?> )</td>
<?php if ( strpos( $method[1], "'" ) ): ?>
<td><?php echo $f->$class->$method[0]( '$method[1]' ) ?></td>
<?php else: ?>
<td><?php echo $f->$class->$method[0]( $method[1] ) ?></td>
<?php endif ?>
</tr>
<?php
} else {
?>
<tr>
<td>$f-><?php echo $class ?>-><?php echo $method ?></td>
<td><?php echo $f->$class->$method ?></td>
</tr>
<?php
}
}
}

?>
<?php for ($i = 0; $i < 10; $i++):?>
<?php
foreach ($arr as $class => $methods) {
foreach ($methods as $method) {
if ( is_array( $method ) ) {
?>
<tr>
<td>Faker::<?php echo $class ?>-><?php echo $method[0] ?>( <?php echo $method[1] ?> )</td>
<?php if ( strpos( $method[1], "'" ) ): ?>
<td><?php echo call_user_func(array('Faker', $class))->$method[0]( '$method[1]' ) ?></td>
<?php else: ?>
<td><?php echo call_user_func(array('Faker', $class))->$method[0]( $method[1] ) ?></td>
<?php endif ?>
</tr>
<?php
} else {
?>
<tr>
<td>Faker::<?php echo $class ?>-><?php echo $method ?>()</td>
<td><?php echo call_user_func(array('Faker', $class))->$method() ?></td>
</tr>
<?php
}
}
}

?>
<?php endfor;?>

</table>

Expand Down
Loading