public function create($collection, array $options = [])
    {
        if (is_string($collection)) {
            $name       = $collection;
            $collection = new Collection();
            $collection->setName($name);
            foreach ($options as $key => $value) {
                $collection->{'set' . ucfirst($key)}($value);
            }
        }
        if ($collection->getWaitForSync() === null) {
            $collection->setWaitForSync($this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC));
        }

        if ($collection->getJournalSize() === null) {
            $collection->setJournalSize($this->getConnectionOption(ConnectionOptions::OPTION_JOURNAL_SIZE));
        }

        if ($collection->getIsSystem() === null) {
            $collection->setIsSystem($this->getConnectionOption(ConnectionOptions::OPTION_IS_SYSTEM));
        }

        if ($collection->getIsVolatile() === null) {
            $collection->setIsVolatile($this->getConnectionOption(ConnectionOptions::OPTION_IS_VOLATILE));
        }

        $type   = $collection->getType() ?: Collection::getDefaultType();
        $params = [
            Collection::ENTRY_NAME         => $collection->getName(),
            Collection::ENTRY_TYPE         => $type,
            Collection::ENTRY_WAIT_SYNC    => $collection->getWaitForSync(),
            Collection::ENTRY_JOURNAL_SIZE => $collection->getJournalSize(),
            Collection::ENTRY_IS_SYSTEM    => $collection->getIsSystem(),
            Collection::ENTRY_IS_VOLATILE  => $collection->getIsVolatile(),
            Collection::ENTRY_KEY_OPTIONS  => $collection->getKeyOptions(),
        ];

        // set extra cluster attributes
        if ($collection->getNumberOfShards() !== null) {
            $params[Collection::ENTRY_NUMBER_OF_SHARDS] = $collection->getNumberOfShards();
        }
        
        if ($collection->getReplicationFactor() !== null) {
            $params[Collection::ENTRY_REPLICATION_FACTOR] = $collection->getReplicationFactor();
        }
        
        if ($collection->getShardingStrategy() !== null) {
            $params[Collection::ENTRY_SHARDING_STRATEGY] = $collection->getShardingStrategy();
        }

        if (is_array($collection->getShardKeys())) {
            $params[Collection::ENTRY_SHARD_KEYS] = $collection->getShardKeys();
        }

        $response = $this->getConnection()->post(Urls::URL_COLLECTION, $this->json_encode_wrapper($params));

        //    $location = $response->getLocationHeader();
        //    if (!$location) {
        //      throw new ClientException('Did not find location header in server response');
        //    }
        $jsonResponse = $response->getJson();
        $id           = $jsonResponse['id'];
        $collection->setId($id);

        return $id;
    }
public function create($collection, array $options = [])
    {
        if (is_string($collection)) {
            $name       = $collection;
            $collection = new Collection();
            $collection->setName($name);
            foreach ($options as $key => $value) {
                $collection->{'set' . ucfirst($key)}($value);
            }
        }
        if ($collection->getWaitForSync() === null) {
            $collection->setWaitForSync($this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC));
        }

        if ($collection->getJournalSize() === null) {
            $collection->setJournalSize($this->getConnectionOption(ConnectionOptions::OPTION_JOURNAL_SIZE));
        }

        if ($collection->getIsSystem() === null) {
            $collection->setIsSystem($this->getConnectionOption(ConnectionOptions::OPTION_IS_SYSTEM));
        }

        if ($collection->getIsVolatile() === null) {
            $collection->setIsVolatile($this->getConnectionOption(ConnectionOptions::OPTION_IS_VOLATILE));
        }

        $type   = $collection->getType() ?: Collection::getDefaultType();
        $params = [
            Collection::ENTRY_NAME         => $collection->getName(),
            Collection::ENTRY_TYPE         => $type,
            Collection::ENTRY_WAIT_SYNC    => $collection->getWaitForSync(),
            Collection::ENTRY_JOURNAL_SIZE => $collection->getJournalSize(),
            Collection::ENTRY_IS_SYSTEM    => $collection->getIsSystem(),
            Collection::ENTRY_IS_VOLATILE  => $collection->getIsVolatile(),
            Collection::ENTRY_KEY_OPTIONS  => $collection->getKeyOptions(),
        ];

        // set extra cluster attributes
        if ($collection->getNumberOfShards() !== null) {
            $params[Collection::ENTRY_NUMBER_OF_SHARDS] = $collection->getNumberOfShards();
        }
        
        if ($collection->getReplicationFactor() !== null) {
            $params[Collection::ENTRY_REPLICATION_FACTOR] = $collection->getReplicationFactor();
        }
        
        if ($collection->getShardingStrategy() !== null) {
            $params[Collection::ENTRY_SHARDING_STRATEGY] = $collection->getShardingStrategy();
        }

        if (is_array($collection->getShardKeys())) {
            $params[Collection::ENTRY_SHARD_KEYS] = $collection->getShardKeys();
        }

        $response = $this->getConnection()->post(Urls::URL_COLLECTION, $this->json_encode_wrapper($params));

        //    $location = $response->getLocationHeader();
        //    if (!$location) {
        //      throw new ClientException('Did not find location header in server response');
        //    }
        $jsonResponse = $response->getJson();
        $id           = $jsonResponse['id'];
        $collection->setId($id);

        return $id;
    }
public function create ( $ collection , array $ options = [ ] ) { if ( is_string ( $ collection ) ) { $ name = $ collection ; $ collection = new Collection ( ) ; $ collection -> setName ( $ name ) ; foreach ( $ options as $ key => $ value ) { $ collection -> { 'set' . ucfirst ( $ key ) } ( $ value ) ; } } if ( $ collection -> getWaitForSync ( ) === null ) { $ collection -> setWaitForSync ( $ this -> getConnectionOption ( ConnectionOptions :: OPTION_WAIT_SYNC ) ) ; } if ( $ collection -> getJournalSize ( ) === null ) { $ collection -> setJournalSize ( $ this -> getConnectionOption ( ConnectionOptions :: OPTION_JOURNAL_SIZE ) ) ; } if ( $ collection -> getIsSystem ( ) === null ) { $ collection -> setIsSystem ( $ this -> getConnectionOption ( ConnectionOptions :: OPTION_IS_SYSTEM ) ) ; } if ( $ collection -> getIsVolatile ( ) === null ) { $ collection -> setIsVolatile ( $ this -> getConnectionOption ( ConnectionOptions :: OPTION_IS_VOLATILE ) ) ; } $ type = $ collection -> getType ( ) ? : Collection :: getDefaultType ( ) ; $ params = [ Collection :: ENTRY_NAME => $ collection -> getName ( ) , Collection :: ENTRY_TYPE => $ type , Collection :: ENTRY_WAIT_SYNC => $ collection -> getWaitForSync ( ) , Collection :: ENTRY_JOURNAL_SIZE => $ collection -> getJournalSize ( ) , Collection :: ENTRY_IS_SYSTEM => $ collection -> getIsSystem ( ) , Collection :: ENTRY_IS_VOLATILE => $ collection -> getIsVolatile ( ) , Collection :: ENTRY_KEY_OPTIONS => $ collection -> getKeyOptions ( ) , ] ; // set extra cluster attributes if ( $ collection -> getNumberOfShards ( ) !== null ) { $ params [ Collection :: ENTRY_NUMBER_OF_SHARDS ] = $ collection -> getNumberOfShards ( ) ; } if ( $ collection -> getReplicationFactor ( ) !== null ) { $ params [ Collection :: ENTRY_REPLICATION_FACTOR ] = $ collection -> getReplicationFactor ( ) ; } if ( $ collection -> getShardingStrategy ( ) !== null ) { $ params [ Collection :: ENTRY_SHARDING_STRATEGY ] = $ collection -> getShardingStrategy ( ) ; } if ( is_array ( $ collection -> getShardKeys ( ) ) ) { $ params [ Collection :: ENTRY_SHARD_KEYS ] = $ collection -> getShardKeys ( ) ; } $ response = $ this -> getConnection ( ) -> post ( Urls :: URL_COLLECTION , $ this -> json_encode_wrapper ( $ params ) ) ; //    $location = $response->getLocationHeader(); //    if (!$location) { //      throw new ClientException('Did not find location header in server response'); //    } $ jsonResponse = $ response -> getJson ( ) ; $ id = $ jsonResponse [ 'id' ] ; $ collection -> setId ( $ id ) ; return $ id ; }
Creates a new collection on the server

This will add the collection on the server and return its id
The id is mainly returned for backwards compatibility, but you should use the collection name for any reference to the collection.   *
This will throw if the collection cannot be created

@throws Exception

@param mixed $collection - collection object to be created on the server or a string with the name
@param array $options    - an array of options.
<p>Options are :<br>
<li>'type'              - 2 -> normal collection, 3 -> edge-collection</li>
<li>'waitForSync'       - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.</li>
<li>'journalSize'       - journalSize value.</li>
<li>'isSystem'          - false->user collection(default), true->system collection .</li>
<li>'isVolatile'        - false->persistent collection(default), true->volatile (in-memory) collection .</li>
<li>'keyOptions'        - key options to use.</li>
<li>'numberOfShards'    - number of shards for the collection.</li>
<li>'shardKeys'         - array of shard key attributes.</li>
<li>'replicationFactor' - number of replicas to keep (default: 1).</li>
<li>'shardingStrategy'  - sharding strategy to use in cluster.</li>
</p>

@return mixed - id of collection created
Creates a new collection on the server