Ejemplo n.º 1
0
 public static function randLocation($items = -1) {
   $rawLocations = PkTestGenerator::randData(static::$ca_cities, $items);
   if ($items === -1) return static::locationAssoc($rawLocations);
   $assocLocs = [];
   foreach ($rawLocations as $rawLocation) {
     $assocLocs[] = static::locationAssoc($rawLocation);
   }
   return $assocLocs;
 }
Ejemplo n.º 2
0
 /**
  * Return a random instance, or array (collection) of random instances
  * @param integer $num: If -1 (default), return single instance. 
  *   if ($num >= 0) return array/collection of $num instances
  * @param array $params - Can be used by subclasses to filter
  * @return instance|array instances - 
  */
 public static function getRandomInstances($num = -1, $params = [])
 {
     if ($num === 0) {
         return [];
     }
     $instances = static::all();
     $numinst = count($instances);
     if (!$numinst) {
         if ($num === -1) {
             return null;
         }
         return [];
     }
     return PkTestGenerator::getRandomData($instances, $num);
 }