public Random::object($size = 4)
Generates a random PHP object.
int $size: The number of random keys to add to the object.
\stdClass The generated object, with the specified number of random keys. Each key has a random string value.
public function object($size = 4) { $object = new \stdClass(); for ($i = 0; $i < $size; $i++) { $random_key = $this->name(); $random_value = $this->string(); $object->{$random_key} = $random_value; } return $object; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Random.php/function/Random::object/8.1.x