Skip to content

Commit

Permalink
Improvement in the preparation of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizaco committed Feb 18, 2013
1 parent c33a420 commit a5b340d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Zizaco/FactoryMuff/FactoryMuff.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ public function attributesFor( $model, $attr = array() )
}

// Prepare attributes
$attr_array = array();
foreach ( $static_vars['factory'] as $key => $kind ) {
$attr_array[$key] = $this->generateAttr( $kind );
if ( ! isset($attr[$key]) ){
$attr[$key] = $this->generateAttr( $kind );
}
}

$attr_array = array_merge( $attr_array, $attr );

return $attr_array;
return $attr;
}

/**
Expand Down Expand Up @@ -162,7 +161,7 @@ private function generateAttr( $kind )

// Pick some words
case 'text':
for ( $i=0; $i < ( (int)date( 'U' ) % 8 ) + 2; $i++ ) {
for ( $i=0; $i < ( (int)date( 'U' )+rand(0,5) % 8 ) + 2; $i++ ) {
$result .= array_pop( $this->wordlist )." ";
}

Expand Down

0 comments on commit a5b340d

Please sign in to comment.