Alcaeus\MongoDbAdapter\TypeConverter::isNumericArray PHP Method

isNumericArray() public static method

For performance reason, this method checks the first array index only. More thorough inspection of the array might be needed. Note: Returns true for empty arrays to preserve compatibility with empty lists.
public static isNumericArray ( array $array ) : boolean
$array array
return boolean
    public static function isNumericArray(array $array)
    {
        return $array === [] || is_numeric(array_keys($array)[0]);
    }

Usage Example

 /**
  * @link http://www.php.net/manual/en/mongocollection.aggregate.php
  * @param array $pipeline
  * @param array $op
  * @return array
  */
 public function aggregate(array $pipeline, array $op = [])
 {
     if (!TypeConverter::isNumericArray($pipeline)) {
         $pipeline = [];
         $options = [];
         $i = 0;
         foreach (func_get_args() as $operator) {
             $i++;
             if (!is_array($operator)) {
                 trigger_error("Argument {$i} is not an array", E_WARNING);
                 return;
             }
             $pipeline[] = $operator;
         }
     } else {
         $options = $op;
     }
     $command = ['aggregate' => $this->name, 'pipeline' => $pipeline];
     $command += $options;
     return $this->db->command($command, [], $hash);
 }
All Usage Examples Of Alcaeus\MongoDbAdapter\TypeConverter::isNumericArray