-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from scottrobertson/fix-undefined-id and fixed…
… conflicts
- Loading branch information
Showing
1 changed file
with
33 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php namespace Zizaco\FactoryMuff; | ||
|
||
/** | ||
* Creates models with randomic attributes | ||
* Creates models with random attributes | ||
* | ||
* @package Zizaco\FactoryMuff | ||
* @author Zizaco <[email protected]> | ||
|
@@ -29,7 +29,7 @@ class FactoryMuff | |
*/ | ||
private $mail_domains = array( | ||
'example.com', 'dontexist.com', | ||
'mockdoman.com', 'emailprovider.com', | ||
'mockdomain.com', 'emailprovider.com', | ||
'exampledomain.org' | ||
); | ||
|
||
|
@@ -104,7 +104,7 @@ public function instance( $model, $attr = array() ) | |
|
||
/** | ||
* Returns an array of mock attributes | ||
* for the especified model | ||
* for the specified model | ||
* | ||
* @param string $model Model class name. | ||
* @param array $attr Model attributes. | ||
|
@@ -237,44 +237,52 @@ private function generateAttr( $kind, $model = NULL ) | |
} | ||
else { | ||
|
||
if ( is_string($kind) && substr( $kind, 0, 8 ) === 'integer|' ) { | ||
$numgen = substr( $kind, 8 ); | ||
|
||
for ( $i=0; $i<$numgen; $i++ ) { | ||
$result .= mt_rand(0,9); | ||
} | ||
} | ||
|
||
// Overwise interpret the kind and 'generate' some | ||
// crap. | ||
switch ( $kind ) { | ||
|
||
// Pick a word and append a domain | ||
case 'email': | ||
shuffle( $this->mail_domains ); | ||
// Pick a word and append a domain | ||
case 'email': | ||
shuffle( $this->mail_domains ); | ||
|
||
$result = $this->getWord().'@'.$this->mail_domains[0]; | ||
break; | ||
$result = $this->getWord().'@'.$this->mail_domains[0]; | ||
break; | ||
|
||
// Pick some words | ||
case 'text': | ||
for ( $i=0; $i < ( ((int)date( 'U' )+rand(0,5)) % 8 ) + 2; $i++ ) { | ||
$result .= $this->getWord()." "; | ||
} | ||
// Pick some words | ||
case 'text': | ||
for ( $i=0; $i < ( ((int)date( 'U' )+rand(0,5)) % 8 ) + 2; $i++ ) { | ||
$result .= $this->getWord()." "; | ||
} | ||
|
||
$result = trim( $result ); | ||
break; | ||
$result = trim( $result ); | ||
break; | ||
|
||
// Pick a single word then | ||
case 'string': | ||
$result = $this->getWord(); | ||
// Pick a single word | ||
case 'string': | ||
$result = $this->getWord(); | ||
|
||
if (rand(0,1)) | ||
$result = ucfirst($result); | ||
if (rand(0,1)) | ||
$result = ucfirst($result); | ||
|
||
break; | ||
break; | ||
|
||
/** | ||
* ITS HERE: The point where you can extend | ||
* this class, to support new datatypes | ||
*/ | ||
|
||
// Returns the original string or number | ||
default: | ||
$result = $kind; | ||
break; | ||
// Returns the original string or number | ||
default: | ||
$result = $kind; | ||
break; | ||
} | ||
|
||
} | ||
|