Exemplo n.º 1
0
 /**
  * Get $num names
  * @param $num
  * @param $additionalColumns
  * @return array
  * @throws \Exception
  */
 public function get($num, $additionalColumns = [])
 {
     $out = [];
     // check that all columns are allowed
     foreach ($additionalColumns as $column) {
         if (!in_array($column, $this->allowedColumns)) {
             throw new \Exception('column ' . $column . ' not allowed');
         }
     }
     for ($i = 0; $i < $num; $i++) {
         $item = [];
         $item['gender'] = Gender::getRandom();
         $item['first'] = $item['gender'] == Gender::GENDER_MALE ? $this->maleNames->getRandom() : $this->femaleNames->getRandom();
         $item['last'] = $this->lastNames->getRandom();
         $item['full'] = $item['first'] . ' ' . $item['last'];
         foreach ($additionalColumns as $column) {
             $item[$column] = $this->{$column}();
         }
         $out[] = $item;
     }
     return $out;
 }