Phalcon\Db\Adapter\MongoDB\Operation\CreateIndexes::__construct PHP Метод

__construct() публичный Метод

Constructs a createIndexes command.
public __construct ( string $databaseName, string $collectionName, array $indexes )
$databaseName string Database name
$collectionName string Collection name
$indexes array List of index specifications
    public function __construct($databaseName, $collectionName, array $indexes)
    {
        if (empty($indexes)) {
            throw new InvalidArgumentException('$indexes is empty');
        }
        $expectedIndex = 0;
        foreach ($indexes as $i => $index) {
            if ($i !== $expectedIndex) {
                throw new InvalidArgumentException(sprintf('$indexes is not a list (unexpected index: "%s")', $i));
            }
            if (!is_array($index)) {
                throw InvalidArgumentException::invalidType(sprintf('$index[%d]', $i), $index, 'array');
            }
            if (!isset($index['ns'])) {
                $index['ns'] = $databaseName . '.' . $collectionName;
            }
            $this->indexes[] = new IndexInput($index);
            $expectedIndex += 1;
        }
        $this->databaseName = (string) $databaseName;
        $this->collectionName = (string) $collectionName;
    }