repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
arangodb/arangodb-php
examples/customDocumentClass.php
AbstractCollection.removeDocument
public function removeDocument(AbstractEntity $document, $options = []) { return $this->removeByKeys($this->_collectionName, [$document->getInternalKey()], $options); }
php
public function removeDocument(AbstractEntity $document, $options = []) { return $this->removeByKeys($this->_collectionName, [$document->getInternalKey()], $options); }
[ "public", "function", "removeDocument", "(", "AbstractEntity", "$", "document", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "removeByKeys", "(", "$", "this", "->", "_collectionName", ",", "[", "$", "document", "->", "getInter...
Removes specified document from collection @param AbstractEntity $document @param $options @return array - an array containing an attribute 'removed' with the number of documents that were deleted, an an array 'ignored' with the number of not removed keys/documents
[ "Removes", "specified", "document", "from", "collection" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/examples/customDocumentClass.php#L263-L266
arangodb/arangodb-php
lib/ArangoDBClient/Graph.php
Graph.set
public function set($key, $value) { if ($key === self::ENTRY_EDGE_DEFINITIONS) { if ($this->_doValidate) { ValueValidator::validate($value); } $edgeDefinitionBaseObject = new EdgeDefinition(); foreach ($value as $ed) { $edgeDefinition = clone $edgeDefinitionBaseObject; foreach ($ed[self::ENTRY_FROM] as $from) { $edgeDefinition->addFromCollection($from); } foreach ($ed[self::ENTRY_TO] as $to) { $edgeDefinition->addToCollection($to); } $edgeDefinition->setRelation($ed[self::ENTRY_COLLECTION]); $this->addEdgeDefinition($edgeDefinition); } } else if ($key === self::ENTRY_ORPHAN_COLLECTIONS) { if ($this->_doValidate) { ValueValidator::validate($value); } foreach ($value as $o) { $this->addOrphanCollection($o); } } else { parent::set($key, $value); } }
php
public function set($key, $value) { if ($key === self::ENTRY_EDGE_DEFINITIONS) { if ($this->_doValidate) { ValueValidator::validate($value); } $edgeDefinitionBaseObject = new EdgeDefinition(); foreach ($value as $ed) { $edgeDefinition = clone $edgeDefinitionBaseObject; foreach ($ed[self::ENTRY_FROM] as $from) { $edgeDefinition->addFromCollection($from); } foreach ($ed[self::ENTRY_TO] as $to) { $edgeDefinition->addToCollection($to); } $edgeDefinition->setRelation($ed[self::ENTRY_COLLECTION]); $this->addEdgeDefinition($edgeDefinition); } } else if ($key === self::ENTRY_ORPHAN_COLLECTIONS) { if ($this->_doValidate) { ValueValidator::validate($value); } foreach ($value as $o) { $this->addOrphanCollection($o); } } else { parent::set($key, $value); } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", "===", "self", "::", "ENTRY_EDGE_DEFINITIONS", ")", "{", "if", "(", "$", "this", "->", "_doValidate", ")", "{", "ValueValidator", "::", "validate", "(", ...
Set a graph attribute The key (attribute name) must be a string. This will validate the value of the attribute and might throw an exception if the value is invalid. @throws ClientException @param string $key - attribute name @param mixed $value - value for attribute @return void
[ "Set", "a", "graph", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Graph.php#L158-L190
arangodb/arangodb-php
lib/ArangoDBClient/Graph.php
Graph.getSingleUndirectedRelation
private function getSingleUndirectedRelation() { $ed = $this->getEdgeDefinitions(); if (count($ed) > 0) { $a = $ed[0]; $b = $a->getFromCollections(); $c = $a->getToCollections(); } if (count($ed) > 1 || ( count($ed) === 1 && ( count($a->getFromCollections()) > 1 || count($a->getToCollections()) > 1 || $b[0] !== $c[0] ) ) ) { throw new ClientException('This operation only supports graphs with one undirected single collection relation'); } if (count($ed) === 1) { $eD = $ed[0]; $this->_edgeDefinitions = []; } else { $eD = new EdgeDefinition(); } return $eD; }
php
private function getSingleUndirectedRelation() { $ed = $this->getEdgeDefinitions(); if (count($ed) > 0) { $a = $ed[0]; $b = $a->getFromCollections(); $c = $a->getToCollections(); } if (count($ed) > 1 || ( count($ed) === 1 && ( count($a->getFromCollections()) > 1 || count($a->getToCollections()) > 1 || $b[0] !== $c[0] ) ) ) { throw new ClientException('This operation only supports graphs with one undirected single collection relation'); } if (count($ed) === 1) { $eD = $ed[0]; $this->_edgeDefinitions = []; } else { $eD = new EdgeDefinition(); } return $eD; }
[ "private", "function", "getSingleUndirectedRelation", "(", ")", "{", "$", "ed", "=", "$", "this", "->", "getEdgeDefinitions", "(", ")", ";", "if", "(", "count", "(", "$", "ed", ")", ">", "0", ")", "{", "$", "a", "=", "$", "ed", "[", "0", "]", ";"...
returns (or creates) the edge definition for single-vertexcollection-undirected graphs, throw an exception for any other type of graph. @throws ClientException @return EdgeDefinition
[ "returns", "(", "or", "creates", ")", "the", "edge", "definition", "for", "single", "-", "vertexcollection", "-", "undirected", "graphs", "throw", "an", "exception", "for", "any", "other", "type", "of", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Graph.php#L198-L226
arangodb/arangodb-php
lib/ArangoDBClient/Transaction.php
Transaction.execute
public function execute() { $response = $this->_connection->post( Urls::URL_TRANSACTION, $this->getConnection()->json_encode_wrapper($this->attributes) ); $responseArray = $response->getJson(); if (isset($responseArray['result'])) { return $responseArray['result']; } return true; }
php
public function execute() { $response = $this->_connection->post( Urls::URL_TRANSACTION, $this->getConnection()->json_encode_wrapper($this->attributes) ); $responseArray = $response->getJson(); if (isset($responseArray['result'])) { return $responseArray['result']; } return true; }
[ "public", "function", "execute", "(", ")", "{", "$", "response", "=", "$", "this", "->", "_connection", "->", "post", "(", "Urls", "::", "URL_TRANSACTION", ",", "$", "this", "->", "getConnection", "(", ")", "->", "json_encode_wrapper", "(", "$", "this", ...
Execute the transaction This will post the query to the server and return the results as a Cursor. The cursor can then be used to iterate the results. @throws Exception throw exception if transaction failed @return mixed true if successful without a return value or the return value if one was set in the action
[ "Execute", "the", "transaction" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Transaction.php#L155-L167
arangodb/arangodb-php
lib/ArangoDBClient/Transaction.php
Transaction.setCollections
public function setCollections(array $value) { if (array_key_exists('read', $value)) { $this->setReadCollections($value['read']); } if (array_key_exists('write', $value)) { $this->setWriteCollections($value['write']); } }
php
public function setCollections(array $value) { if (array_key_exists('read', $value)) { $this->setReadCollections($value['read']); } if (array_key_exists('write', $value)) { $this->setWriteCollections($value['write']); } }
[ "public", "function", "setCollections", "(", "array", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "'read'", ",", "$", "value", ")", ")", "{", "$", "this", "->", "setReadCollections", "(", "$", "value", "[", "'read'", "]", ")", ";", "}",...
Set the collections array. The array should have 2 sub-arrays, namely 'read' and 'write' which should hold the respective collections for the transaction @param array $value
[ "Set", "the", "collections", "array", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Transaction.php#L189-L197
arangodb/arangodb-php
lib/ArangoDBClient/Transaction.php
Transaction.get
public function get($key) { switch ($key) { case 'writeCollections' : return $this->getWriteCollections(); break; case 'readCollections' : return $this->getReadCollections(); break; } if (isset($this->attributes[$key])) { return $this->attributes[$key]; } return null; }
php
public function get($key) { switch ($key) { case 'writeCollections' : return $this->getWriteCollections(); break; case 'readCollections' : return $this->getReadCollections(); break; } if (isset($this->attributes[$key])) { return $this->attributes[$key]; } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'writeCollections'", ":", "return", "$", "this", "->", "getWriteCollections", "(", ")", ";", "break", ";", "case", "'readCollections'", ":", "return", "...
Get an attribute @param string $key - name of attribute @return mixed - value of attribute, NULL if attribute is not set
[ "Get", "an", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Transaction.php#L430-L446
arangodb/arangodb-php
lib/ArangoDBClient/Transaction.php
Transaction.buildTransactionAttributesFromArray
public function buildTransactionAttributesFromArray($options) { if (isset($options[self::ENTRY_COLLECTIONS])) { $this->setCollections($options[self::ENTRY_COLLECTIONS]); } if (isset($options[self::ENTRY_ACTION])) { $this->setAction($options[self::ENTRY_ACTION]); } if (isset($options[self::ENTRY_WAIT_FOR_SYNC])) { $this->setWaitForSync($options[self::ENTRY_WAIT_FOR_SYNC]); } if (isset($options[self::ENTRY_LOCK_TIMEOUT])) { $this->setLockTimeout($options[self::ENTRY_LOCK_TIMEOUT]); } if (isset($options[self::ENTRY_PARAMS])) { $this->setParams($options[self::ENTRY_PARAMS]); } }
php
public function buildTransactionAttributesFromArray($options) { if (isset($options[self::ENTRY_COLLECTIONS])) { $this->setCollections($options[self::ENTRY_COLLECTIONS]); } if (isset($options[self::ENTRY_ACTION])) { $this->setAction($options[self::ENTRY_ACTION]); } if (isset($options[self::ENTRY_WAIT_FOR_SYNC])) { $this->setWaitForSync($options[self::ENTRY_WAIT_FOR_SYNC]); } if (isset($options[self::ENTRY_LOCK_TIMEOUT])) { $this->setLockTimeout($options[self::ENTRY_LOCK_TIMEOUT]); } if (isset($options[self::ENTRY_PARAMS])) { $this->setParams($options[self::ENTRY_PARAMS]); } }
[ "public", "function", "buildTransactionAttributesFromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "self", "::", "ENTRY_COLLECTIONS", "]", ")", ")", "{", "$", "this", "->", "setCollections", "(", "$", "options", "[", ...
Build the object's attributes from a given array @param $options @throws \ArangoDBClient\ClientException
[ "Build", "the", "object", "s", "attributes", "from", "a", "given", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Transaction.php#L503-L524
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.execute
public function execute() { if (!is_string($this->_query)) { throw new ClientException('Query should be a string'); } $data = $this->buildData(); $tries = 0; while (true) { try { $response = $this->_connection->post(Urls::URL_CURSOR, $this->getConnection()->json_encode_wrapper($data), []); return new Cursor($this->_connection, $response->getJson(), $this->getCursorOptions()); } catch (ServerException $e) { if ($tries++ >= $this->_retries) { throw $e; } if ($e->getServerCode() !== 29) { // 29 is "deadlock detected" throw $e; } // try again } } }
php
public function execute() { if (!is_string($this->_query)) { throw new ClientException('Query should be a string'); } $data = $this->buildData(); $tries = 0; while (true) { try { $response = $this->_connection->post(Urls::URL_CURSOR, $this->getConnection()->json_encode_wrapper($data), []); return new Cursor($this->_connection, $response->getJson(), $this->getCursorOptions()); } catch (ServerException $e) { if ($tries++ >= $this->_retries) { throw $e; } if ($e->getServerCode() !== 29) { // 29 is "deadlock detected" throw $e; } // try again } } }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "_query", ")", ")", "{", "throw", "new", "ClientException", "(", "'Query should be a string'", ")", ";", "}", "$", "data", "=", "$", "this", "->", "bui...
Execute the statement This will post the query to the server and return the results as a Cursor. The cursor can then be used to iterate the results. @throws Exception @return Cursor
[ "Execute", "the", "statement" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L308-L333
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.explain
public function explain() { $data = $this->buildData(); $response = $this->_connection->post(Urls::URL_EXPLAIN, $this->getConnection()->json_encode_wrapper($data), []); return $response->getJson(); }
php
public function explain() { $data = $this->buildData(); $response = $this->_connection->post(Urls::URL_EXPLAIN, $this->getConnection()->json_encode_wrapper($data), []); return $response->getJson(); }
[ "public", "function", "explain", "(", ")", "{", "$", "data", "=", "$", "this", "->", "buildData", "(", ")", ";", "$", "response", "=", "$", "this", "->", "_connection", "->", "post", "(", "Urls", "::", "URL_EXPLAIN", ",", "$", "this", "->", "getConne...
Explain the statement's execution plan This will post the query to the server and return the execution plan as an array. @throws Exception @return array
[ "Explain", "the", "statement", "s", "execution", "plan" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L344-L350
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.validate
public function validate() { $data = $this->buildData(); $response = $this->_connection->post(Urls::URL_QUERY, $this->getConnection()->json_encode_wrapper($data), []); return $response->getJson(); }
php
public function validate() { $data = $this->buildData(); $response = $this->_connection->post(Urls::URL_QUERY, $this->getConnection()->json_encode_wrapper($data), []); return $response->getJson(); }
[ "public", "function", "validate", "(", ")", "{", "$", "data", "=", "$", "this", "->", "buildData", "(", ")", ";", "$", "response", "=", "$", "this", "->", "_connection", "->", "post", "(", "Urls", "::", "URL_QUERY", ",", "$", "this", "->", "getConnec...
Validates the statement This will post the query to the server for validation and return the validation result as an array. @throws Exception @return array
[ "Validates", "the", "statement" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L361-L367
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.setBatchSize
public function setBatchSize($value) { if (!is_int($value) || (int) $value <= 0) { throw new ClientException('Batch size should be a positive integer'); } $this->_batchSize = (int) $value; }
php
public function setBatchSize($value) { if (!is_int($value) || (int) $value <= 0) { throw new ClientException('Batch size should be a positive integer'); } $this->_batchSize = (int) $value; }
[ "public", "function", "setBatchSize", "(", "$", "value", ")", "{", "if", "(", "!", "is_int", "(", "$", "value", ")", "||", "(", "int", ")", "$", "value", "<=", "0", ")", "{", "throw", "new", "ClientException", "(", "'Batch size should be a positive integer...
Set the batch size for the statement The batch size is the number of results to be transferred in one server round-trip. If a query produces more results than the batch size, it creates a server-side cursor that provides the additional results. The server-side cursor can be accessed by the client with subsequent HTTP requests. @throws ClientException @param int $value - batch size value @return void
[ "Set", "the", "batch", "size", "for", "the", "statement" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L640-L647
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.buildData
private function buildData() { $data = [ self::ENTRY_QUERY => $this->_query, self::ENTRY_COUNT => $this->_doCount, 'options' => [ self::FULL_COUNT => $this->_fullCount, self::ENTRY_FAIL_ON_WARNING => $this->_failOnWarning ] ]; if ($this->_stream !== null) { $data['options'][self::ENTRY_STREAM] = $this->_stream; } if ($this->_ttl !== null) { $data[self::ENTRY_TTL] = $this->_ttl; } if ($this->_cache !== null) { $data[Cursor::ENTRY_CACHE] = $this->_cache; } if ($this->_memoryLimit > 0) { $data[self::ENTRY_MEMORY_LIMIT] = $this->_memoryLimit; } if ($this->_bindVars->getCount() > 0) { $data[self::ENTRY_BINDVARS] = $this->_bindVars->getAll(); } if ($this->_batchSize > 0) { $data[self::ENTRY_BATCHSIZE] = $this->_batchSize; } return $data; }
php
private function buildData() { $data = [ self::ENTRY_QUERY => $this->_query, self::ENTRY_COUNT => $this->_doCount, 'options' => [ self::FULL_COUNT => $this->_fullCount, self::ENTRY_FAIL_ON_WARNING => $this->_failOnWarning ] ]; if ($this->_stream !== null) { $data['options'][self::ENTRY_STREAM] = $this->_stream; } if ($this->_ttl !== null) { $data[self::ENTRY_TTL] = $this->_ttl; } if ($this->_cache !== null) { $data[Cursor::ENTRY_CACHE] = $this->_cache; } if ($this->_memoryLimit > 0) { $data[self::ENTRY_MEMORY_LIMIT] = $this->_memoryLimit; } if ($this->_bindVars->getCount() > 0) { $data[self::ENTRY_BINDVARS] = $this->_bindVars->getAll(); } if ($this->_batchSize > 0) { $data[self::ENTRY_BATCHSIZE] = $this->_batchSize; } return $data; }
[ "private", "function", "buildData", "(", ")", "{", "$", "data", "=", "[", "self", "::", "ENTRY_QUERY", "=>", "$", "this", "->", "_query", ",", "self", "::", "ENTRY_COUNT", "=>", "$", "this", "->", "_doCount", ",", "'options'", "=>", "[", "self", "::", ...
Build an array of data to be posted to the server when issuing the statement @return array - array of data to be sent to server
[ "Build", "an", "array", "of", "data", "to", "be", "posted", "to", "the", "server", "when", "issuing", "the", "statement" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L665-L701
arangodb/arangodb-php
lib/ArangoDBClient/Statement.php
Statement.getCursorOptions
private function getCursorOptions() { $result = [ Cursor::ENTRY_SANITIZE => (bool) $this->_sanitize, Cursor::ENTRY_FLAT => (bool) $this->_flat, Cursor::ENTRY_BASEURL => Urls::URL_CURSOR ]; if (null !== $this->resultType) { $result[Cursor::ENTRY_TYPE] = $this->resultType; } if ($this->_documentClass !== null && $this->_documentClass !== '') { $result['_documentClass'] = $this->_documentClass; } return $result; }
php
private function getCursorOptions() { $result = [ Cursor::ENTRY_SANITIZE => (bool) $this->_sanitize, Cursor::ENTRY_FLAT => (bool) $this->_flat, Cursor::ENTRY_BASEURL => Urls::URL_CURSOR ]; if (null !== $this->resultType) { $result[Cursor::ENTRY_TYPE] = $this->resultType; } if ($this->_documentClass !== null && $this->_documentClass !== '') { $result['_documentClass'] = $this->_documentClass; } return $result; }
[ "private", "function", "getCursorOptions", "(", ")", "{", "$", "result", "=", "[", "Cursor", "::", "ENTRY_SANITIZE", "=>", "(", "bool", ")", "$", "this", "->", "_sanitize", ",", "Cursor", "::", "ENTRY_FLAT", "=>", "(", "bool", ")", "$", "this", "->", "...
Return an array of cursor options @return array - array of options
[ "Return", "an", "array", "of", "cursor", "options" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Statement.php#L708-L724
arangodb/arangodb-php
lib/ArangoDBClient/EdgeDefinition.php
EdgeDefinition.transformToArray
public function transformToArray() { $transformedEd = []; $transformedEd['collection'] = $this->getRelation(); $transformedEd['from'] = $this->getFromCollections(); $transformedEd['to'] = $this->getToCollections(); return $transformedEd; }
php
public function transformToArray() { $transformedEd = []; $transformedEd['collection'] = $this->getRelation(); $transformedEd['from'] = $this->getFromCollections(); $transformedEd['to'] = $this->getToCollections(); return $transformedEd; }
[ "public", "function", "transformToArray", "(", ")", "{", "$", "transformedEd", "=", "[", "]", ";", "$", "transformedEd", "[", "'collection'", "]", "=", "$", "this", "->", "getRelation", "(", ")", ";", "$", "transformedEd", "[", "'from'", "]", "=", "$", ...
Transforms an edge definition to an array. @return array @since 2.2
[ "Transforms", "an", "edge", "definition", "to", "an", "array", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/EdgeDefinition.php#L165-L173
arangodb/arangodb-php
lib/ArangoDBClient/QueryCacheHandler.php
QueryCacheHandler.disable
public function disable() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, ['properties']); $this->getConnection()->put($url, $this->json_encode_wrapper(['mode' => 'off'])); }
php
public function disable() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, ['properties']); $this->getConnection()->put($url, $this->json_encode_wrapper(['mode' => 'off'])); }
[ "public", "function", "disable", "(", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_QUERY_CACHE", ",", "[", "'properties'", "]", ")", ";", "$", "this", "->", "getConnection", "(", ")", "->", "put", "(", "$", "url", ...
Globally turns off the AQL query result cache @throws Exception
[ "Globally", "turns", "off", "the", "AQL", "query", "result", "cache" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/QueryCacheHandler.php#L33-L37
arangodb/arangodb-php
lib/ArangoDBClient/QueryCacheHandler.php
QueryCacheHandler.clear
public function clear() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, []); $this->getConnection()->delete($url); }
php
public function clear() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, []); $this->getConnection()->delete($url); }
[ "public", "function", "clear", "(", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_QUERY_CACHE", ",", "[", "]", ")", ";", "$", "this", "->", "getConnection", "(", ")", "->", "delete", "(", "$", "url", ")", ";", "}...
Clears the AQL query result cache for the current database @throws Exception
[ "Clears", "the", "AQL", "query", "result", "cache", "for", "the", "current", "database" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/QueryCacheHandler.php#L56-L60
arangodb/arangodb-php
lib/ArangoDBClient/QueryCacheHandler.php
QueryCacheHandler.getEntries
public function getEntries() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, ['entries']); $result = $this->getConnection()->get($url); return $result->getJson(); }
php
public function getEntries() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE, ['entries']); $result = $this->getConnection()->get($url); return $result->getJson(); }
[ "public", "function", "getEntries", "(", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_QUERY_CACHE", ",", "[", "'entries'", "]", ")", ";", "$", "result", "=", "$", "this", "->", "getConnection", "(", ")", "->", "get"...
Returns the entries from the query cache in current database @throws Exception @return array - entries in query cache
[ "Returns", "the", "entries", "from", "the", "query", "cache", "in", "current", "database" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/QueryCacheHandler.php#L70-L76
arangodb/arangodb-php
lib/ArangoDBClient/QueryCacheHandler.php
QueryCacheHandler.setProperties
public function setProperties(array $properties) { $bodyParams = $properties; $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($bodyParams)); return $response->getJson(); }
php
public function setProperties(array $properties) { $bodyParams = $properties; $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($bodyParams)); return $response->getJson(); }
[ "public", "function", "setProperties", "(", "array", "$", "properties", ")", "{", "$", "bodyParams", "=", "$", "properties", ";", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_QUERY_CACHE", ")", ";", "$", "response", "=", "$", "...
Adjusts the global AQL query result cache properties @throws Exception @param array $properties - the query result cache properties. the following properties can be used: - maxResults: maximum number of results that the query result cache will hold per database - mode: turns the query result cache on or off, or sets it to demand mode. Possible values are "on", "off", or "demand". @return array
[ "Adjusts", "the", "global", "AQL", "query", "result", "cache", "properties" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/QueryCacheHandler.php#L94-L102
arangodb/arangodb-php
lib/ArangoDBClient/QueryCacheHandler.php
QueryCacheHandler.getProperties
public function getProperties() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE); $response = $this->getConnection()->get($url); return $response->getJson(); }
php
public function getProperties() { $url = UrlHelper::buildUrl(Urls::URL_QUERY_CACHE); $response = $this->getConnection()->get($url); return $response->getJson(); }
[ "public", "function", "getProperties", "(", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_QUERY_CACHE", ")", ";", "$", "response", "=", "$", "this", "->", "getConnection", "(", ")", "->", "get", "(", "$", "url", ")",...
Returns the AQL query result cache properties @throws Exception @return array
[ "Returns", "the", "AQL", "query", "result", "cache", "properties" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/QueryCacheHandler.php#L111-L117
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.create
public function create(View $view) { $params = [ View::ENTRY_NAME => $view->getName(), View::ENTRY_TYPE => $view->getType(), ]; $url = Urls::URL_VIEW; $response = $this->getConnection()->post($url, $this->json_encode_wrapper($params)); $json = $response->getJson(); $view->setId($json[View::ENTRY_ID]); return $view->getAll(); }
php
public function create(View $view) { $params = [ View::ENTRY_NAME => $view->getName(), View::ENTRY_TYPE => $view->getType(), ]; $url = Urls::URL_VIEW; $response = $this->getConnection()->post($url, $this->json_encode_wrapper($params)); $json = $response->getJson(); $view->setId($json[View::ENTRY_ID]); return $view->getAll(); }
[ "public", "function", "create", "(", "View", "$", "view", ")", "{", "$", "params", "=", "[", "View", "::", "ENTRY_NAME", "=>", "$", "view", "->", "getName", "(", ")", ",", "View", "::", "ENTRY_TYPE", "=>", "$", "view", "->", "getType", "(", ")", ",...
Create a view This will create a view using the given view object and return an array of the created view object's attributes.<br><br> @throws Exception @param View $view - The view object which holds the information of the view to be created @return array @since 3.4
[ "Create", "a", "view" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L40-L52
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.get
public function get($view) { $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view]); $response = $this->getConnection()->get($url); $data = $response->getJson(); $result = new View($data[View::ENTRY_NAME], $data[View::ENTRY_TYPE]); $result->setId($data[View::ENTRY_ID]); return $result; }
php
public function get($view) { $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view]); $response = $this->getConnection()->get($url); $data = $response->getJson(); $result = new View($data[View::ENTRY_NAME], $data[View::ENTRY_TYPE]); $result->setId($data[View::ENTRY_ID]); return $result; }
[ "public", "function", "get", "(", "$", "view", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_VIEW", ",", "[", "$", "view", "]", ")", ";", "$", "response", "=", "$", "this", "->", "getConnection", "(", ")", "->", ...
Get a view This will get a view.<br><br> @param String $view - The name of the view @return View|false @throws \ArangoDBClient\ClientException @since 3.4
[ "Get", "a", "view" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L65-L76
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.properties
public function properties($view) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view, 'properties']); $result = $this->getConnection()->get($url); return $result->getJson(); }
php
public function properties($view) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view, 'properties']); $result = $this->getConnection()->get($url); return $result->getJson(); }
[ "public", "function", "properties", "(", "$", "view", ")", "{", "if", "(", "$", "view", "instanceof", "View", ")", "{", "$", "view", "=", "$", "view", "->", "getName", "(", ")", ";", "}", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls",...
Get a view's properties<br><br> @throws Exception @param mixed $view - view name as a string or instance of View @return array - Returns an array of attributes. Will throw if there is an error @since 3.4
[ "Get", "a", "view", "s", "properties<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L88-L98
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.setProperties
public function setProperties($view, array $properties) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view, 'properties']); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($properties)); $json = $response->getJson(); return $json; }
php
public function setProperties($view, array $properties) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view, 'properties']); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($properties)); $json = $response->getJson(); return $json; }
[ "public", "function", "setProperties", "(", "$", "view", ",", "array", "$", "properties", ")", "{", "if", "(", "$", "view", "instanceof", "View", ")", "{", "$", "view", "=", "$", "view", "->", "getName", "(", ")", ";", "}", "$", "url", "=", "UrlHel...
Set a view's properties<br><br> @throws Exception @param mixed $view - view name as a string or instance of View @param array $properties - array with view properties @return array - Returns an array of attributes. Will throw if there is an error @since 3.4
[ "Set", "a", "view", "s", "properties<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L111-L122
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.drop
public function drop($view) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view]); $this->getConnection()->delete($url); return true; }
php
public function drop($view) { if ($view instanceof View) { $view = $view->getName(); } $url = UrlHelper::buildUrl(Urls::URL_VIEW, [$view]); $this->getConnection()->delete($url); return true; }
[ "public", "function", "drop", "(", "$", "view", ")", "{", "if", "(", "$", "view", "instanceof", "View", ")", "{", "$", "view", "=", "$", "view", "->", "getName", "(", ")", ";", "}", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::...
Drop a view<br><br> @throws Exception @param mixed $view - view name as a string or instance of View @return bool - always true, will throw if there is an error @since 3.4
[ "Drop", "a", "view<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L135-L145
arangodb/arangodb-php
lib/ArangoDBClient/ViewHandler.php
ViewHandler.rename
public function rename($view, $name) { if ($view instanceof View) { $view = $view->getName(); } $params = [View::ENTRY_NAME => $name]; $this->getConnection()->put( UrlHelper::buildUrl(Urls::URL_VIEW, [$view, self::OPTION_RENAME]), $this->json_encode_wrapper($params) ); return true; }
php
public function rename($view, $name) { if ($view instanceof View) { $view = $view->getName(); } $params = [View::ENTRY_NAME => $name]; $this->getConnection()->put( UrlHelper::buildUrl(Urls::URL_VIEW, [$view, self::OPTION_RENAME]), $this->json_encode_wrapper($params) ); return true; }
[ "public", "function", "rename", "(", "$", "view", ",", "$", "name", ")", "{", "if", "(", "$", "view", "instanceof", "View", ")", "{", "$", "view", "=", "$", "view", "->", "getName", "(", ")", ";", "}", "$", "params", "=", "[", "View", "::", "EN...
Rename a view @throws Exception @param mixed $view - view name as a string or instance of View @param string $name - new name for collection @return bool - always true, will throw if there is an error
[ "Rename", "a", "view" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ViewHandler.php#L157-L170
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.createFromArray
public static function createFromArray($values, array $options = []) { $document = new static($options); foreach ($values as $key => $value) { $document->set($key, $value); } $document->setChanged(true); return $document; }
php
public static function createFromArray($values, array $options = []) { $document = new static($options); foreach ($values as $key => $value) { $document->set($key, $value); } $document->setChanged(true); return $document; }
[ "public", "static", "function", "createFromArray", "(", "$", "values", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "new", "static", "(", "$", "options", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>",...
Factory method to construct a new document using the values passed to populate it @throws ClientException @param array $values - initial values for document @param array $options - optional, initial options for document @return Document|Edge|Graph
[ "Factory", "method", "to", "construct", "a", "new", "document", "using", "the", "values", "passed", "to", "populate", "it" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L175-L185
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.filterHiddenAttributes
public function filterHiddenAttributes($attributes, array $_hiddenAttributes = []) { $hiddenAttributes = $_hiddenAttributes !== null ? $_hiddenAttributes : $this->getHiddenAttributes(); if (count($hiddenAttributes) > 0) { foreach ($hiddenAttributes as $hiddenAttributeName) { if (isset($attributes[$hiddenAttributeName])) { unset($attributes[$hiddenAttributeName]); } } } unset ($attributes[self::ENTRY_HIDDENATTRIBUTES]); return $attributes; }
php
public function filterHiddenAttributes($attributes, array $_hiddenAttributes = []) { $hiddenAttributes = $_hiddenAttributes !== null ? $_hiddenAttributes : $this->getHiddenAttributes(); if (count($hiddenAttributes) > 0) { foreach ($hiddenAttributes as $hiddenAttributeName) { if (isset($attributes[$hiddenAttributeName])) { unset($attributes[$hiddenAttributeName]); } } } unset ($attributes[self::ENTRY_HIDDENATTRIBUTES]); return $attributes; }
[ "public", "function", "filterHiddenAttributes", "(", "$", "attributes", ",", "array", "$", "_hiddenAttributes", "=", "[", "]", ")", "{", "$", "hiddenAttributes", "=", "$", "_hiddenAttributes", "!==", "null", "?", "$", "_hiddenAttributes", ":", "$", "this", "->...
Returns the attributes with the hidden ones removed @param array $attributes - attributes array @param array $_hiddenAttributes @return array - attributes array
[ "Returns", "the", "attributes", "with", "the", "hidden", "ones", "removed" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L261-L276
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.set
public function set($key, $value) { if ($this->_doValidate) { // validate the value passed ValueValidator::validate($value); } if ($key[0] === '_') { if ($key === self::ENTRY_ID) { $this->setInternalId($value); return; } if ($key === self::ENTRY_KEY) { $this->setInternalKey($value); return; } if ($key === self::ENTRY_REV) { $this->setRevision($value); return; } if ($key === self::ENTRY_ISNEW) { $this->setIsNew($value); return; } } if (!$this->_changed) { if (!isset($this->_values[$key]) || $this->_values[$key] !== $value) { // set changed flag $this->_changed = true; } } // and store the value $this->_values[$key] = $value; }
php
public function set($key, $value) { if ($this->_doValidate) { // validate the value passed ValueValidator::validate($value); } if ($key[0] === '_') { if ($key === self::ENTRY_ID) { $this->setInternalId($value); return; } if ($key === self::ENTRY_KEY) { $this->setInternalKey($value); return; } if ($key === self::ENTRY_REV) { $this->setRevision($value); return; } if ($key === self::ENTRY_ISNEW) { $this->setIsNew($value); return; } } if (!$this->_changed) { if (!isset($this->_values[$key]) || $this->_values[$key] !== $value) { // set changed flag $this->_changed = true; } } // and store the value $this->_values[$key] = $value; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "_doValidate", ")", "{", "// validate the value passed", "ValueValidator", "::", "validate", "(", "$", "value", ")", ";", "}", "if", "(", "$", "key...
Set a document attribute The key (attribute name) must be a string. This will validate the value of the attribute and might throw an exception if the value is invalid. @throws ClientException @param string $key - attribute name @param mixed $value - value for attribute @return void
[ "Set", "a", "document", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L292-L334
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.get
public function get($key) { if (isset($this->_values[$key])) { return $this->_values[$key]; } return null; }
php
public function get($key) { if (isset($this->_values[$key])) { return $this->_values[$key]; } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_values", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_values", "[", "$", "key", "]", ";", "}", "return", "null", ";", ...
Get a document attribute @param string $key - name of attribute @return mixed - value of attribute, NULL if attribute is not set
[ "Get", "a", "document", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L364-L371
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.getAll
public function getAll(array $options = []) { // This preserves compatibility for the old includeInternals parameter. $includeInternals = false; $ignoreHiddenAttributes = $this->{self::ENTRY_IGNOREHIDDENATTRIBUTES}; $_hiddenAttributes = $this->{self::ENTRY_HIDDENATTRIBUTES}; if (!is_array($options)) { $includeInternals = $options; } else { // keeping the non-underscored version for backwards-compatibility $includeInternals = array_key_exists( 'includeInternals', $options ) ? $options['includeInternals'] : $includeInternals; $includeInternals = array_key_exists( '_includeInternals', $options ) ? $options['_includeInternals'] : $includeInternals; // keeping the non-underscored version for backwards-compatibility $ignoreHiddenAttributes = array_key_exists( 'ignoreHiddenAttributes', $options ) ? $options['ignoreHiddenAttributes'] : $ignoreHiddenAttributes; $ignoreHiddenAttributes = array_key_exists( self::ENTRY_IGNOREHIDDENATTRIBUTES, $options ) ? $options[self::ENTRY_IGNOREHIDDENATTRIBUTES] : $ignoreHiddenAttributes; $_hiddenAttributes = array_key_exists( self::ENTRY_HIDDENATTRIBUTES, $options ) ? $options[self::ENTRY_HIDDENATTRIBUTES] : $_hiddenAttributes; } $data = $this->_values; $nonInternals = ['_changed', '_values', self::ENTRY_HIDDENATTRIBUTES]; if ($includeInternals === true) { foreach ($this as $key => $value) { if ($key[0] === '_' && 0 !== strpos($key, '__') && !in_array($key, $nonInternals, true)) { $data[$key] = $value; } } } if ($ignoreHiddenAttributes === false) { $data = $this->filterHiddenAttributes($data, $_hiddenAttributes); } if (null !== $this->_key) { $data['_key'] = $this->_key; } return $data; }
php
public function getAll(array $options = []) { // This preserves compatibility for the old includeInternals parameter. $includeInternals = false; $ignoreHiddenAttributes = $this->{self::ENTRY_IGNOREHIDDENATTRIBUTES}; $_hiddenAttributes = $this->{self::ENTRY_HIDDENATTRIBUTES}; if (!is_array($options)) { $includeInternals = $options; } else { // keeping the non-underscored version for backwards-compatibility $includeInternals = array_key_exists( 'includeInternals', $options ) ? $options['includeInternals'] : $includeInternals; $includeInternals = array_key_exists( '_includeInternals', $options ) ? $options['_includeInternals'] : $includeInternals; // keeping the non-underscored version for backwards-compatibility $ignoreHiddenAttributes = array_key_exists( 'ignoreHiddenAttributes', $options ) ? $options['ignoreHiddenAttributes'] : $ignoreHiddenAttributes; $ignoreHiddenAttributes = array_key_exists( self::ENTRY_IGNOREHIDDENATTRIBUTES, $options ) ? $options[self::ENTRY_IGNOREHIDDENATTRIBUTES] : $ignoreHiddenAttributes; $_hiddenAttributes = array_key_exists( self::ENTRY_HIDDENATTRIBUTES, $options ) ? $options[self::ENTRY_HIDDENATTRIBUTES] : $_hiddenAttributes; } $data = $this->_values; $nonInternals = ['_changed', '_values', self::ENTRY_HIDDENATTRIBUTES]; if ($includeInternals === true) { foreach ($this as $key => $value) { if ($key[0] === '_' && 0 !== strpos($key, '__') && !in_array($key, $nonInternals, true)) { $data[$key] = $value; } } } if ($ignoreHiddenAttributes === false) { $data = $this->filterHiddenAttributes($data, $_hiddenAttributes); } if (null !== $this->_key) { $data['_key'] = $this->_key; } return $data; }
[ "public", "function", "getAll", "(", "array", "$", "options", "=", "[", "]", ")", "{", "// This preserves compatibility for the old includeInternals parameter.", "$", "includeInternals", "=", "false", ";", "$", "ignoreHiddenAttributes", "=", "$", "this", "->", "{", ...
Get all document attributes @param mixed $options - optional, array of options for the getAll function, or the boolean value for $includeInternals <p>Options are : <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li> <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li> </p> @return array - array of all document attributes/values
[ "Get", "all", "document", "attributes" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L431-L489
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.getAllForInsertUpdate
public function getAllForInsertUpdate() { $data = []; foreach ($this->_values as $key => $value) { if ($key === '_id' || $key === '_rev') { continue; } if ($key === '_key' && $value === null) { // key value not yet set continue; } $data[$key] = $value; } if ($this->_key !== null) { $data['_key'] = $this->_key; } return $data; }
php
public function getAllForInsertUpdate() { $data = []; foreach ($this->_values as $key => $value) { if ($key === '_id' || $key === '_rev') { continue; } if ($key === '_key' && $value === null) { // key value not yet set continue; } $data[$key] = $value; } if ($this->_key !== null) { $data['_key'] = $this->_key; } return $data; }
[ "public", "function", "getAllForInsertUpdate", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "'_id'", "||", "$", "key", ...
Get all document attributes for insertion/update @return mixed - associative array of all document attributes/values
[ "Get", "all", "document", "attributes", "for", "insertion", "/", "update" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L496-L515
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.getAllAsObject
public function getAllAsObject(array $options = []) { $result = $this->getAll($options); if (count($result) === 0) { return new \stdClass(); } return $result; }
php
public function getAllAsObject(array $options = []) { $result = $this->getAll($options); if (count($result) === 0) { return new \stdClass(); } return $result; }
[ "public", "function", "getAllAsObject", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "result", "=", "$", "this", "->", "getAll", "(", "$", "options", ")", ";", "if", "(", "count", "(", "$", "result", ")", "===", "0", ")", "{", "ret...
Get all document attributes, and return an empty object if the documentapped into a DocumentWrapper class @param mixed $options - optional, array of options for the getAll function, or the boolean value for $includeInternals <p>Options are : <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li> <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li> </p> @return mixed - associative array of all document attributes/values, or an empty StdClass if the document does not have any
[ "Get", "all", "document", "attributes", "and", "return", "an", "empty", "object", "if", "the", "documentapped", "into", "a", "DocumentWrapper", "class" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L530-L538
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.setInternalId
public function setInternalId($id) { if ($this->_id !== null && $this->_id !== $id) { throw new ClientException('Should not update the id of an existing document'); } if (!preg_match('/^[a-zA-Z0-9_-]{1,64}\/[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $id)) { throw new ClientException('Invalid format for document id'); } $this->_id = (string) $id; }
php
public function setInternalId($id) { if ($this->_id !== null && $this->_id !== $id) { throw new ClientException('Should not update the id of an existing document'); } if (!preg_match('/^[a-zA-Z0-9_-]{1,64}\/[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $id)) { throw new ClientException('Invalid format for document id'); } $this->_id = (string) $id; }
[ "public", "function", "setInternalId", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "_id", "!==", "null", "&&", "$", "this", "->", "_id", "!==", "$", "id", ")", "{", "throw", "new", "ClientException", "(", "'Should not update the id of an existi...
Set the internal document id This will throw if the id of an existing document gets updated to some other id @throws ClientException @param string $id - internal document id @return void
[ "Set", "the", "internal", "document", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L634-L646
arangodb/arangodb-php
lib/ArangoDBClient/Document.php
Document.setInternalKey
public function setInternalKey($key) { if ($this->_key !== null && $this->_key !== $key) { throw new ClientException('Should not update the key of an existing document'); } if (!preg_match('/^[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $key)) { throw new ClientException('Invalid format for document key'); } $this->_key = (string) $key; }
php
public function setInternalKey($key) { if ($this->_key !== null && $this->_key !== $key) { throw new ClientException('Should not update the key of an existing document'); } if (!preg_match('/^[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $key)) { throw new ClientException('Invalid format for document key'); } $this->_key = (string) $key; }
[ "public", "function", "setInternalKey", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "_key", "!==", "null", "&&", "$", "this", "->", "_key", "!==", "$", "key", ")", "{", "throw", "new", "ClientException", "(", "'Should not update the key of an ...
Set the internal document key This will throw if the key of an existing document gets updated to some other key @throws ClientException @param string $key - internal document key @return void
[ "Set", "the", "internal", "document", "key" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Document.php#L659-L670
arangodb/arangodb-php
lib/ArangoDBClient/EdgeHandler.php
EdgeHandler.createFromArrayWithContext
public function createFromArrayWithContext($data, $options) { $_edgeClass = $this->_edgeClass; return $_edgeClass::createFromArray($data, $options); }
php
public function createFromArrayWithContext($data, $options) { $_edgeClass = $this->_edgeClass; return $_edgeClass::createFromArray($data, $options); }
[ "public", "function", "createFromArrayWithContext", "(", "$", "data", ",", "$", "options", ")", "{", "$", "_edgeClass", "=", "$", "this", "->", "_edgeClass", ";", "return", "$", "_edgeClass", "::", "createFromArray", "(", "$", "data", ",", "$", "options", ...
Intermediate function to call the createFromArray function from the right context @param $data @param $options @return Edge @throws \ArangoDBClient\ClientException
[ "Intermediate", "function", "to", "call", "the", "createFromArray", "function", "from", "the", "right", "context" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/EdgeHandler.php#L88-L93
arangodb/arangodb-php
lib/ArangoDBClient/EdgeHandler.php
EdgeHandler.saveEdge
public function saveEdge($collection, $from, $to, $document, array $options = []) { $collection = $this->makeCollection($collection); if (is_array($document)) { $_edgeClass = $this->_edgeClass; $document = $_edgeClass::createFromArray($document); } $document->setFrom($from); $document->setTo($to); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'createCollection' => $this->getConnectionOption(ConnectionOptions::OPTION_CREATE) ] ); $this->createCollectionIfOptions($collection, $params); $data = $document->getAllForInsertUpdate(); $url = UrlHelper::appendParamsUrl(Urls::URL_EDGE . '/' . $collection, $params); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); $location = $response->getLocationHeader(); if (!$location) { throw new ClientException('Did not find location header in server response'); } $json = $response->getJson(); $id = UrlHelper::getDocumentIdFromLocation($location); $document->setInternalId($json[Edge::ENTRY_ID]); $document->setRevision($json[Edge::ENTRY_REV]); if ($id !== $document->getId()) { throw new ClientException('Got an invalid response from the server'); } $document->setIsNew(false); return $document->getId(); }
php
public function saveEdge($collection, $from, $to, $document, array $options = []) { $collection = $this->makeCollection($collection); if (is_array($document)) { $_edgeClass = $this->_edgeClass; $document = $_edgeClass::createFromArray($document); } $document->setFrom($from); $document->setTo($to); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'createCollection' => $this->getConnectionOption(ConnectionOptions::OPTION_CREATE) ] ); $this->createCollectionIfOptions($collection, $params); $data = $document->getAllForInsertUpdate(); $url = UrlHelper::appendParamsUrl(Urls::URL_EDGE . '/' . $collection, $params); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); $location = $response->getLocationHeader(); if (!$location) { throw new ClientException('Did not find location header in server response'); } $json = $response->getJson(); $id = UrlHelper::getDocumentIdFromLocation($location); $document->setInternalId($json[Edge::ENTRY_ID]); $document->setRevision($json[Edge::ENTRY_REV]); if ($id !== $document->getId()) { throw new ClientException('Got an invalid response from the server'); } $document->setIsNew(false); return $document->getId(); }
[ "public", "function", "saveEdge", "(", "$", "collection", ",", "$", "from", ",", "$", "to", ",", "$", "document", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "collection", "=", "$", "this", "->", "makeCollection", "(", "$", "collectio...
save an edge to an edge-collection This will save the edge to the collection and return the edges-document's id This will throw if the document cannot be saved @throws Exception @param mixed $collection - collection id as string or number @param mixed $from - from vertex @param mixed $to - to vertex @param mixed $document - the edge-document to be added, can be passed as an object or an array @param array $options - optional, array of options. <p>Options are :<br> <li>'createCollection' - create the collection if it does not yet exist.</li> <li>'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk.<br> If this is not specified, then the collection's default sync behavior will be applied.</li> </p> @return mixed - id of document created @since 1.0
[ "save", "an", "edge", "to", "an", "edge", "-", "collection" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/EdgeHandler.php#L140-L183
arangodb/arangodb-php
lib/ArangoDBClient/EdgeHandler.php
EdgeHandler.edges
public function edges($collection, $vertexHandle, $direction = 'any', array $options = []) { $collection = $this->makeCollection($collection); $params = [ self::OPTION_VERTEX => $vertexHandle, self::OPTION_DIRECTION => $direction ]; $url = UrlHelper::appendParamsUrl(Urls::URL_EDGES . '/' . urlencode($collection), $params); $response = $this->getConnection()->get($url); if ($batchPart = $response->getBatchPart()) { return $batchPart; } $options['_isNew'] = false; $json = $response->getJson(); $edges = []; foreach ($json[self::ENTRY_EDGES] as $data) { $edges[] = $this->createFromArrayWithContext($data, $options); } return $edges; }
php
public function edges($collection, $vertexHandle, $direction = 'any', array $options = []) { $collection = $this->makeCollection($collection); $params = [ self::OPTION_VERTEX => $vertexHandle, self::OPTION_DIRECTION => $direction ]; $url = UrlHelper::appendParamsUrl(Urls::URL_EDGES . '/' . urlencode($collection), $params); $response = $this->getConnection()->get($url); if ($batchPart = $response->getBatchPart()) { return $batchPart; } $options['_isNew'] = false; $json = $response->getJson(); $edges = []; foreach ($json[self::ENTRY_EDGES] as $data) { $edges[] = $this->createFromArrayWithContext($data, $options); } return $edges; }
[ "public", "function", "edges", "(", "$", "collection", ",", "$", "vertexHandle", ",", "$", "direction", "=", "'any'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "collection", "=", "$", "this", "->", "makeCollection", "(", "$", "collect...
Get connected edges for a given vertex @throws Exception @param mixed $collection - edge-collection id as string or number @param mixed $vertexHandle - the vertex involved @param string $direction - optional defaults to 'any'. Other possible Values 'in' & 'out' @param array $options - optional, array of options <p>Options are : <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li> <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li> </p> @return array - array of connected edges @since 1.0
[ "Get", "connected", "edges", "for", "a", "given", "vertex" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/EdgeHandler.php#L203-L226
arangodb/arangodb-php
lib/ArangoDBClient/ServerException.php
ServerException.getServerCode
public function getServerCode() { if (isset($this->_details[self::ENTRY_CODE])) { return $this->_details[self::ENTRY_CODE]; } return $this->getCode(); }
php
public function getServerCode() { if (isset($this->_details[self::ENTRY_CODE])) { return $this->_details[self::ENTRY_CODE]; } return $this->getCode(); }
[ "public", "function", "getServerCode", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_details", "[", "self", "::", "ENTRY_CODE", "]", ")", ")", "{", "return", "$", "this", "->", "_details", "[", "self", "::", "ENTRY_CODE", "]", ";", "}"...
Get server error code If the server has provided additional details about the error that occurred, this will return the server error code @return int - server error code
[ "Get", "server", "error", "code" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ServerException.php#L94-L101
arangodb/arangodb-php
lib/ArangoDBClient/ServerException.php
ServerException.getServerMessage
public function getServerMessage() { if (isset($this->_details[self::ENTRY_MESSAGE])) { return $this->_details[self::ENTRY_MESSAGE]; } return null; }
php
public function getServerMessage() { if (isset($this->_details[self::ENTRY_MESSAGE])) { return $this->_details[self::ENTRY_MESSAGE]; } return null; }
[ "public", "function", "getServerMessage", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_details", "[", "self", "::", "ENTRY_MESSAGE", "]", ")", ")", "{", "return", "$", "this", "->", "_details", "[", "self", "::", "ENTRY_MESSAGE", "]", "...
Get server error message If the server has provided additional details about the error that occurred, this will return the server error string @return string - server error message
[ "Get", "server", "error", "message" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/ServerException.php#L111-L118
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.createGraph
public function createGraph(Graph $graph) { $edgeDefinitions = []; foreach ($graph->getEdgeDefinitions() as $ed) { $edgeDefinitions[] = $ed->transformToArray(); } $params = [ self::OPTION_NAME => $graph->getKey(), self::OPTION_EDGE_DEFINITIONS => $edgeDefinitions, self::OPTION_ORPHAN_COLLECTIONS => $graph->getOrphanCollections() ]; $url = Urls::URL_GRAPH; $response = $this->getConnection()->post($url, $this->json_encode_wrapper($params)); $json = $response->getJson(); $graph->setInternalId($json['graph'][Graph::ENTRY_ID]); $graph->set(Graph::ENTRY_KEY, $json['graph'][self::OPTION_NAME]); $graph->setRevision($json['graph'][Graph::ENTRY_REV]); return $graph->getAll(); }
php
public function createGraph(Graph $graph) { $edgeDefinitions = []; foreach ($graph->getEdgeDefinitions() as $ed) { $edgeDefinitions[] = $ed->transformToArray(); } $params = [ self::OPTION_NAME => $graph->getKey(), self::OPTION_EDGE_DEFINITIONS => $edgeDefinitions, self::OPTION_ORPHAN_COLLECTIONS => $graph->getOrphanCollections() ]; $url = Urls::URL_GRAPH; $response = $this->getConnection()->post($url, $this->json_encode_wrapper($params)); $json = $response->getJson(); $graph->setInternalId($json['graph'][Graph::ENTRY_ID]); $graph->set(Graph::ENTRY_KEY, $json['graph'][self::OPTION_NAME]); $graph->setRevision($json['graph'][Graph::ENTRY_REV]); return $graph->getAll(); }
[ "public", "function", "createGraph", "(", "Graph", "$", "graph", ")", "{", "$", "edgeDefinitions", "=", "[", "]", ";", "foreach", "(", "$", "graph", "->", "getEdgeDefinitions", "(", ")", "as", "$", "ed", ")", "{", "$", "edgeDefinitions", "[", "]", "=",...
Create a graph This will create a graph using the given graph object and return an array of the created graph object's attributes.<br><br> @throws Exception @param Graph $graph - The graph object which holds the information of the graph to be created @return array @since 1.2
[ "Create", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L107-L127
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.getGraph
public function getGraph($graph, array $options = []) { $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph]); try { $response = $this->getConnection()->get($url); } catch (Exception $e) { return false; } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
php
public function getGraph($graph, array $options = []) { $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph]); try { $response = $this->getConnection()->get($url); } catch (Exception $e) { return false; } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
[ "public", "function", "getGraph", "(", "$", "graph", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_GRAPH", ",", "[", "$", "graph", "]", ")", ";", "try", "{", "$", "r...
Get a graph This will get a graph.<br><br> @param String $graph - The name of the graph @param array $options - Options to pass to the method @return Graph|false @throws \ArangoDBClient\ClientException @since 1.2
[ "Get", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L167-L185
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.properties
public function properties($graph) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_DOCUMENT . '/_graphs', [$graph]); $result = $this->getConnection()->get($url); return $result->getJson(); }
php
public function properties($graph) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_DOCUMENT . '/_graphs', [$graph]); $result = $this->getConnection()->get($url); return $result->getJson(); }
[ "public", "function", "properties", "(", "$", "graph", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Ur...
Get a graph's properties<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @return bool - Returns an array of attributes. Will throw if there is an error @since 1.2
[ "Get", "a", "graph", "s", "properties<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L233-L244
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.dropGraph
public function dropGraph($graph, $dropCollections = true) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph]); $url = UrlHelper::appendParamsUrl($url, ['dropCollections' => $dropCollections]); $this->getConnection()->delete($url); return true; }
php
public function dropGraph($graph, $dropCollections = true) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph]); $url = UrlHelper::appendParamsUrl($url, ['dropCollections' => $dropCollections]); $this->getConnection()->delete($url); return true; }
[ "public", "function", "dropGraph", "(", "$", "graph", ",", "$", "dropCollections", "=", "true", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "$", "url", "="...
Drop a graph and remove all its vertices and edges, also drops vertex and edge collections<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param bool $dropCollections - if set to false the graphs collections will not be dropped. @return bool - always true, will throw if there is an error @since 1.2
[ "Drop", "a", "graph", "and", "remove", "all", "its", "vertices", "and", "edges", "also", "drops", "vertex", "and", "edge", "collections<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L258-L270
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.addOrphanCollection
public function addOrphanCollection($graph, $orphanCollection) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX]); $data = [ self::OPTION_COLLECTION => $orphanCollection ]; try { $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
php
public function addOrphanCollection($graph, $orphanCollection) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX]); $data = [ self::OPTION_COLLECTION => $orphanCollection ]; try { $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
[ "public", "function", "addOrphanCollection", "(", "$", "graph", ",", "$", "orphanCollection", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "$", "url", "=", "U...
add an orphan collection to the graph. This will add a further orphan collection to the graph.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param string $orphanCollection - the orphan collection to be added as string. @return Graph @since 2.2
[ "add", "an", "orphan", "collection", "to", "the", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L286-L311
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.deleteOrphanCollection
public function deleteOrphanCollection($graph, $orphanCollection, $dropCollection = false) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $orphanCollection]); $data = [ self::OPTION_DROP_COLLECTION => $dropCollection ]; $url = UrlHelper::appendParamsUrl($url, $data); try { $response = $this->getConnection()->delete($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
php
public function deleteOrphanCollection($graph, $orphanCollection, $dropCollection = false) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $orphanCollection]); $data = [ self::OPTION_DROP_COLLECTION => $dropCollection ]; $url = UrlHelper::appendParamsUrl($url, $data); try { $response = $this->getConnection()->delete($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
[ "public", "function", "deleteOrphanCollection", "(", "$", "graph", ",", "$", "orphanCollection", ",", "$", "dropCollection", "=", "false", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", ...
deletes an orphan collection from the graph. This will delete an orphan collection from the graph.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param string $orphanCollection - the orphan collection to be removed as string. @param boolean $dropCollection - if set to true the collection is deleted, not just removed from the graph. @return Graph @since 2.2
[ "deletes", "an", "orphan", "collection", "from", "the", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L328-L354
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.getVertexCollections
public function getVertexCollections($graph, array $options = []) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $excludeOrphans = false; $_useCache = $this->cacheEnabled; if ((bool) $options && isset($options['excludeOrphans']) && !is_bool($options['excludeOrphans'])) { $excludeOrphans = UrlHelper::getBoolString($options['excludeOrphans']); } if ($_useCache === true) { if ($excludeOrphans === true && !empty($this->cache[$graph]['excludeOrphans']['result'])) { return $this->cache[$graph]['excludeOrphans']['vertexCollections']; } if (!empty($this->cache[$graph]['vertexCollections'])) { return $this->cache[$graph]['vertexCollections']; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX]); if ($excludeOrphans === true) { $url = UrlHelper::appendParamsUrl($url, ['excludeOrphans' => $excludeOrphans]); } $connection = $this->getConnection(); $batchCaptureMode = $connection->isInBatchCaptureMode(); if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(false); } try { $response = $this->getConnection()->get($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(true); } $data = $response->getJson(); $data = $data[self::OPTION_COLLECTIONS]; sort($data); if ($_useCache === true) { if ($excludeOrphans === true && !empty($this->cache[$graph]['excludeOrphans']['vertexCollections'])) { $this->cache[$graph]['excludeOrphans']['vertexCollections'] = $data; } else { $this->cache[$graph]['vertexCollections'] = $data; } } return $data; }
php
public function getVertexCollections($graph, array $options = []) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $excludeOrphans = false; $_useCache = $this->cacheEnabled; if ((bool) $options && isset($options['excludeOrphans']) && !is_bool($options['excludeOrphans'])) { $excludeOrphans = UrlHelper::getBoolString($options['excludeOrphans']); } if ($_useCache === true) { if ($excludeOrphans === true && !empty($this->cache[$graph]['excludeOrphans']['result'])) { return $this->cache[$graph]['excludeOrphans']['vertexCollections']; } if (!empty($this->cache[$graph]['vertexCollections'])) { return $this->cache[$graph]['vertexCollections']; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX]); if ($excludeOrphans === true) { $url = UrlHelper::appendParamsUrl($url, ['excludeOrphans' => $excludeOrphans]); } $connection = $this->getConnection(); $batchCaptureMode = $connection->isInBatchCaptureMode(); if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(false); } try { $response = $this->getConnection()->get($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(true); } $data = $response->getJson(); $data = $data[self::OPTION_COLLECTIONS]; sort($data); if ($_useCache === true) { if ($excludeOrphans === true && !empty($this->cache[$graph]['excludeOrphans']['vertexCollections'])) { $this->cache[$graph]['excludeOrphans']['vertexCollections'] = $data; } else { $this->cache[$graph]['vertexCollections'] = $data; } } return $data; }
[ "public", "function", "getVertexCollections", "(", "$", "graph", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "...
gets all vertex collection from the graph. This will get all vertex collection (orphans and used in edge definitions) from the graph.<br><br> If this method or any method that calls this method is used in batch mode and caching is off,<br> then for each call, this method will make an out of batch API call to the db in order to get the appropriate collections.<br><br> If caching is on, then the GraphHandler will only call the DB API once for the chosen graph, and return data from cache for the following calls.<br> @param mixed $graph - graph name as a string or instance of Graph @param array $options - optional, an array of options <p>Options are :<br> <li>'excludeOrphans' - boolean value: true to exclude the orphans or false to include orphans in the result.<br> Defaults to false</li> @return array @throws ClientException@since 2.2
[ "gets", "all", "vertex", "collection", "from", "the", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L375-L434
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.addEdgeDefinition
public function addEdgeDefinition($graph, $edgeDefinition) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE]); $data = $edgeDefinition->transformToArray(); try { $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
php
public function addEdgeDefinition($graph, $edgeDefinition) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE]); $data = $edgeDefinition->transformToArray(); try { $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); } catch (Exception $e) { throw new ClientException($e->getMessage()); } $data = $response->getJson(); $options['_isNew'] = false; $result = Graph::createFromArray($data['graph'], $options); $result->set(Graph::ENTRY_KEY, $data['graph'][self::OPTION_NAME]); return $result; }
[ "public", "function", "addEdgeDefinition", "(", "$", "graph", ",", "$", "edgeDefinition", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "$", "url", "=", "UrlHe...
adds an edge definition to the graph. This will add a further edge definition to the graph.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param EdgeDefinition $edgeDefinition - the new edge definition. @return Graph @since 2.2
[ "adds", "an", "edge", "definition", "to", "the", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L450-L474
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.getEdgeCollections
public function getEdgeCollections($graph) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $_useCache = $this->cacheEnabled; if ($_useCache === true && !empty($this->cache[$graph]['edgeCollections'])) { return $this->cache[$graph]['edgeCollections']; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE]); $connection = $this->getConnection(); $batchCaptureMode = $connection->isInBatchCaptureMode(); if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(false); } try { $response = $this->getConnection()->get($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(true); } $data = $response->getJson(); $data = $data[self::OPTION_COLLECTIONS]; sort($data); if ($_useCache === true && !empty($this->cache[$graph]['edgeCollections'])) { $this->cache[$graph]['edgeCollections'] = $data; } return $data; }
php
public function getEdgeCollections($graph) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $_useCache = $this->cacheEnabled; if ($_useCache === true && !empty($this->cache[$graph]['edgeCollections'])) { return $this->cache[$graph]['edgeCollections']; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE]); $connection = $this->getConnection(); $batchCaptureMode = $connection->isInBatchCaptureMode(); if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(false); } try { $response = $this->getConnection()->get($url); } catch (Exception $e) { throw new ClientException($e->getMessage()); } if ($batchCaptureMode === true) { $this->getConnection()->setBatchRequest(true); } $data = $response->getJson(); $data = $data[self::OPTION_COLLECTIONS]; sort($data); if ($_useCache === true && !empty($this->cache[$graph]['edgeCollections'])) { $this->cache[$graph]['edgeCollections'] = $data; } return $data; }
[ "public", "function", "getEdgeCollections", "(", "$", "graph", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}", "$", "_useCache", "=", "$", "this", "->", "cacheEn...
gets all edge collections from the graph. This will get all edge collections from the graph.<br><br> If this method or any method that calls this method is used in batch mode and caching is off,<br> then for each call, this method will make an out of batch API call to the db in order to get the appropriate collections.<br><br> If caching is on, then the GraphHandler will only call the DB API once for the chosen graph, and return data from cache for the following calls.<br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @return array @since 2.2
[ "gets", "all", "edge", "collections", "from", "the", "graph", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L536-L577
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.saveVertex
public function saveVertex($graph, $document, $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } if (is_array($document)) { $_documentClass = $this->_documentClass; $document = $_documentClass::createFromArray($document); } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $data = $document->getAll(); $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection]); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); // This makes sure that if we're in batch mode, it will not go further and choke on the checks below. // Caution: Instead of a document ID, we are returning the batchpart object. // The Id of the BatchPart can be retrieved by calling getId() on it. // We're basically returning an object here, in order not to accidentally use the batch part id as the document id if ($batchPart = $response->getBatchPart()) { return $batchPart; } $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $document->setInternalId($vertex[Vertex::ENTRY_ID]); $document->setRevision($vertex[Vertex::ENTRY_REV]); $document->setIsNew(false); return $document->getInternalId(); }
php
public function saveVertex($graph, $document, $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } if (is_array($document)) { $_documentClass = $this->_documentClass; $document = $_documentClass::createFromArray($document); } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $data = $document->getAll(); $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection]); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); // This makes sure that if we're in batch mode, it will not go further and choke on the checks below. // Caution: Instead of a document ID, we are returning the batchpart object. // The Id of the BatchPart can be retrieved by calling getId() on it. // We're basically returning an object here, in order not to accidentally use the batch part id as the document id if ($batchPart = $response->getBatchPart()) { return $batchPart; } $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $document->setInternalId($vertex[Vertex::ENTRY_ID]); $document->setRevision($vertex[Vertex::ENTRY_REV]); $document->setIsNew(false); return $document->getInternalId(); }
[ "public", "function", "saveVertex", "(", "$", "graph", ",", "$", "document", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", "graph", "->", "getKey", "(", ")", ";", "}...
save a vertex to a graph This will add the vertex-document to the graph and return the vertex id This will throw if the vertex cannot be saved<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $document - the vertex to be added, can be passed as a vertex object or an array @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection to store the vertex. @return string - id of vertex created @since 1.2
[ "save", "a", "vertex", "to", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L636-L682
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.getVertex
public function getVertex($graph, $vertexId, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $response = $this->getConnection()->get($url); $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $options['_isNew'] = false; $_documentClass = $this->_documentClass; return $_documentClass::createFromArray($vertex, $options); }
php
public function getVertex($graph, $vertexId, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $response = $this->getConnection()->get($url); $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $options['_isNew'] = false; $_documentClass = $this->_documentClass; return $_documentClass::createFromArray($vertex, $options); }
[ "public", "function", "getVertex", "(", "$", "graph", ",", "$", "vertexId", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$"...
Get a single vertex from a graph This will throw if the vertex cannot be fetched from the server<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $vertexId - the vertex identifier @param array $options optional, an array of options: <p> <li><b>_includeInternals</b> - true to include the internal attributes. Defaults to false</li> <li><b>_ignoreHiddenAttributes</b> - true to show hidden attributes. Defaults to false</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection to load the vertex. @return Document @since 1.2
[ "Get", "a", "single", "vertex", "from", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L705-L738
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.hasVertex
public function hasVertex($graph, $vertexId) { try { // will throw ServerException if entry could not be retrieved $this->getVertex($graph, $vertexId); return true; } catch (ServerException $e) { // we are expecting a 404 to return boolean false if ($e->getCode() === 404) { return false; } // just rethrow throw $e; } }
php
public function hasVertex($graph, $vertexId) { try { // will throw ServerException if entry could not be retrieved $this->getVertex($graph, $vertexId); return true; } catch (ServerException $e) { // we are expecting a 404 to return boolean false if ($e->getCode() === 404) { return false; } // just rethrow throw $e; } }
[ "public", "function", "hasVertex", "(", "$", "graph", ",", "$", "vertexId", ")", "{", "try", "{", "// will throw ServerException if entry could not be retrieved", "$", "this", "->", "getVertex", "(", "$", "graph", ",", "$", "vertexId", ")", ";", "return", "true"...
Check if a vertex exists This will call self::getVertex() internally and checks if there was an exception thrown which represents an 404 request. @throws Exception When any other error than a 404 occurs @param mixed $graph - graph name as a string or instance of Graph @param mixed $vertexId - the vertex identifier @return boolean
[ "Check", "if", "a", "vertex", "exists" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L754-L770
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.replaceVertex
public function replaceVertex($graph, $vertexId, Document $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY) ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } $data = $document->getAll(); $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data)); $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $document->setInternalId($vertex[Vertex::ENTRY_ID]); $document->setRevision($vertex[Vertex::ENTRY_REV]); return true; }
php
public function replaceVertex($graph, $vertexId, Document $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY) ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } $data = $document->getAll(); $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data)); $jsonArray = $response->getJson(); $vertex = $jsonArray['vertex']; $document->setInternalId($vertex[Vertex::ENTRY_ID]); $document->setRevision($vertex[Vertex::ENTRY_REV]); return true; }
[ "public", "function", "replaceVertex", "(", "$", "graph", ",", "$", "vertexId", ",", "Document", "$", "document", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph"...
Replace an existing vertex in a graph, identified graph name and vertex id This will update the vertex on the server If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the to-be-replaced vertex is the same as the one given.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $vertexId - the vertex id as string or number @param Document $document - the vertex-document to be updated @param mixed $options optional, an array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method): <p> <li><b>revision</b> - revision for conditional updates ('some-revision-id' [use the passed in revision id], false or true [use document's revision])</li> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Replace", "an", "existing", "vertex", "in", "a", "graph", "identified", "graph", "name", "and", "vertex", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L798-L857
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.updateVertex
public function updateVertex($graph, $vertexId, Document $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY) ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll())); $json = $result->getJson(); $vertex = $json['vertex']; $document->setRevision($vertex[Vertex::ENTRY_REV]); return true; }
php
public function updateVertex($graph, $vertexId, Document $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY) ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll())); $json = $result->getJson(); $vertex = $json['vertex']; $document->setRevision($vertex[Vertex::ENTRY_REV]); return true; }
[ "public", "function", "updateVertex", "(", "$", "graph", ",", "$", "vertexId", ",", "Document", "$", "document", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph",...
Update an existing vertex in a graph, identified by graph name and vertex id This will update the vertex on the server This will throw if the vertex cannot be updated If policy is set to error (locally or globally through the ConnectionOptions) and the passed vertex-document has a _rev value set, the database will check that the revision of the to-be-replaced document is the same as the one given.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $vertexId - the vertex id as string or number @param Document $document - the patch vertex-document which contains the attributes and values to be updated @param mixed $options optional, an array of options (see below) <p> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>keepNull</b> - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Update", "an", "existing", "vertex", "in", "a", "graph", "identified", "by", "graph", "name", "and", "vertex", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L887-L939
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.removeVertex
public function removeVertex($graph, $vertexId, $revision = null, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_DELETE_POLICY) ] ); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
php
public function removeVertex($graph, $vertexId, $revision = null, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $vertexId); if (count($parts) === 2) { list($collection, $vertexId) = $parts; } if ($collection === null) { $vertexCollections = $this->getVertexCollections($graph); $vertexCollectionsCount = count($vertexCollections); if ($vertexCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($vertexCollectionsCount === 1) { $collection = $vertexCollections[0]; } } $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_DELETE_POLICY) ] ); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
[ "public", "function", "removeVertex", "(", "$", "graph", ",", "$", "vertexId", ",", "$", "revision", "=", "null", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Grap...
Remove a vertex from a graph, identified by the graph name and vertex id<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $vertexId - the vertex id as string or number @param mixed $revision - optional, the revision of the vertex to be deleted @param mixed $options optional, an array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method) <p> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Remove", "a", "vertex", "from", "a", "graph", "identified", "by", "the", "graph", "name", "and", "vertex", "id<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L960-L1001
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.saveEdge
public function saveEdge($graph, $from, $to, $label = null, $document, $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } if (is_array($document)) { $_edgeClass = $this->_edgeClass; $document = $_edgeClass::createFromArray($document); } if (null !== $label) { $document->set('$label', $label); } $document->setFrom($from); $document->setTo($to); $data = $document->getAll(); $data[self::KEY_FROM] = $from; $data[self::KEY_TO] = $to; $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection]); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $document->setInternalId($edge[Edge::ENTRY_ID]); $document->setRevision($edge[Edge::ENTRY_REV]); $document->setIsNew(false); return $document->getInternalId(); }
php
public function saveEdge($graph, $from, $to, $label = null, $document, $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } if (is_array($document)) { $_edgeClass = $this->_edgeClass; $document = $_edgeClass::createFromArray($document); } if (null !== $label) { $document->set('$label', $label); } $document->setFrom($from); $document->setTo($to); $data = $document->getAll(); $data[self::KEY_FROM] = $from; $data[self::KEY_TO] = $to; $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection]); $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data)); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $document->setInternalId($edge[Edge::ENTRY_ID]); $document->setRevision($edge[Edge::ENTRY_REV]); $document->setIsNew(false); return $document->getInternalId(); }
[ "public", "function", "saveEdge", "(", "$", "graph", ",", "$", "from", ",", "$", "to", ",", "$", "label", "=", "null", ",", "$", "document", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", ...
save an edge to a graph This will save the edge to the graph and return the edges-document's id This will throw if the edge cannot be saved<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $from - the 'from' vertex @param mixed $to - the 'to' vertex @param mixed $label - (optional) a label for the edge @param mixed $document - the edge-document to be added, can be passed as an edge object or an array @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return mixed - id of edge created @since 1.2
[ "save", "an", "edge", "to", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1023-L1067
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.getEdge
public function getEdge($graph, $edgeId, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $response = $this->getConnection()->get($url); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $options['_isNew'] = false; $_edgeClass = $this->_edgeClass; return $_edgeClass::createFromArray($edge, $options); }
php
public function getEdge($graph, $edgeId, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $response = $this->getConnection()->get($url); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $options['_isNew'] = false; $_edgeClass = $this->_edgeClass; return $_edgeClass::createFromArray($edge, $options); }
[ "public", "function", "getEdge", "(", "$", "graph", ",", "$", "edgeId", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ")", "{", "$", "graph", "=", "$", ...
Get a single edge from a graph This will throw if the edge cannot be fetched from the server<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $edgeId - edge identifier @param array $options optional, array of options <p> <li><b>_includeInternals</b> - true to include the internal attributes. Defaults to false</li> <li><b>_ignoreHiddenAttributes</b> - true to show hidden attributes. Defaults to false</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return Document - the edge document fetched from the server @since 1.2
[ "Get", "a", "single", "edge", "from", "a", "graph" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1089-L1121
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.hasEdge
public function hasEdge($graph, $edgeId) { try { // will throw ServerException if entry could not be retrieved $this->getEdge($graph, $edgeId); return true; } catch (ServerException $e) { // we are expecting a 404 to return boolean false if ($e->getCode() === 404) { return false; } // just rethrow throw $e; } }
php
public function hasEdge($graph, $edgeId) { try { // will throw ServerException if entry could not be retrieved $this->getEdge($graph, $edgeId); return true; } catch (ServerException $e) { // we are expecting a 404 to return boolean false if ($e->getCode() === 404) { return false; } // just rethrow throw $e; } }
[ "public", "function", "hasEdge", "(", "$", "graph", ",", "$", "edgeId", ")", "{", "try", "{", "// will throw ServerException if entry could not be retrieved", "$", "this", "->", "getEdge", "(", "$", "graph", ",", "$", "edgeId", ")", ";", "return", "true", ";",...
Check if an edge exists This will call self::getEdge() internally and checks if there was an exception thrown which represents an 404 request. @throws Exception When any other error than a 404 occurs @param mixed $graph - graph name as a string or instance of Graph @param mixed $edgeId - the vertex identifier @return boolean
[ "Check", "if", "an", "edge", "exists" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1137-L1153
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.replaceEdge
public function replaceEdge($graph, $edgeId, $label, Edge $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'silent' => false, 'ignoreRevs' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY), ] ); //Include the revision for conditional updates if required $headers = []; if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params['ignoreRevs'] = false; $headers['if-match'] = '"' . $revision . '"'; } } elseif ($options[self::OPTION_REVISION]) { $revision = $options[self::OPTION_REVISION]; $params['ignoreRevs'] = false; $headers['if-match'] = '"' . $revision . '"'; } $data = $document->getAllForInsertUpdate(); if (null !== $label) { $document->set('$label', $label); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data), $headers); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $document->setInternalId($edge[Edge::ENTRY_ID]); $document->setRevision($edge[Edge::ENTRY_REV]); return true; }
php
public function replaceEdge($graph, $edgeId, $label, Edge $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'silent' => false, 'ignoreRevs' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY), ] ); //Include the revision for conditional updates if required $headers = []; if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params['ignoreRevs'] = false; $headers['if-match'] = '"' . $revision . '"'; } } elseif ($options[self::OPTION_REVISION]) { $revision = $options[self::OPTION_REVISION]; $params['ignoreRevs'] = false; $headers['if-match'] = '"' . $revision . '"'; } $data = $document->getAllForInsertUpdate(); if (null !== $label) { $document->set('$label', $label); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data), $headers); $jsonArray = $response->getJson(); $edge = $jsonArray['edge']; $document->setInternalId($edge[Edge::ENTRY_ID]); $document->setRevision($edge[Edge::ENTRY_REV]); return true; }
[ "public", "function", "replaceEdge", "(", "$", "graph", ",", "$", "edgeId", ",", "$", "label", ",", "Edge", "$", "document", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "insta...
Replace an existing edge in a graph, identified graph name and edge id This will replace the edge on the server This will throw if the edge cannot be Replaced If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the to-be-replaced edge is the same as the one given.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $edgeId - edge id as string or number @param mixed $label - label for the edge or '' @param Edge $document - edge document to be updated @param mixed $options optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method) <p> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Replace", "an", "existing", "edge", "in", "a", "graph", "identified", "graph", "name", "and", "edge", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1183-L1248
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.updateEdge
public function updateEdge($graph, $edgeId, $label, Edge $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY), ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } if (null !== $label) { $document->set('$label', $label); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll())); $json = $result->getJson(); $edge = $json['edge']; $document->setRevision($edge[Edge::ENTRY_REV]); return true; }
php
public function updateEdge($graph, $edgeId, $label, Edge $document, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $options = array_merge([self::OPTION_REVISION => false], $options); $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY), ] ); //Include the revision for conditional updates if required if ($options[self::OPTION_REVISION] === true) { $revision = $document->getRevision(); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } } elseif ($options[self::OPTION_REVISION]) { $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION]; } if (null !== $label) { $document->set('$label', $label); } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll())); $json = $result->getJson(); $edge = $json['edge']; $document->setRevision($edge[Edge::ENTRY_REV]); return true; }
[ "public", "function", "updateEdge", "(", "$", "graph", ",", "$", "edgeId", ",", "$", "label", ",", "Edge", "$", "document", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instan...
Update an existing edge in a graph, identified by graph name and edge id This will update the edge on the server This will throw if the edge cannot be updated If policy is set to error (locally or globally through the ConnectionOptions) and the passed edge-document has a _rev value set, the database will check that the revision of the to-be-replaced document is the same as the one given.<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $edgeId - edge id as string or number @param mixed $label - label for the edge or '' @param Edge $document - patch edge-document which contains the attributes and values to be updated @param mixed $options optional, array of options (see below) <p> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>keepNull</b> - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Update", "an", "existing", "edge", "in", "a", "graph", "identified", "by", "graph", "name", "and", "edge", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1279-L1335
arangodb/arangodb-php
lib/ArangoDBClient/GraphHandler.php
GraphHandler.removeEdge
public function removeEdge($graph, $edgeId, $revision = null, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_DELETE_POLICY), ] ); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
php
public function removeEdge($graph, $edgeId, $revision = null, array $options = [], $collection = null) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $parts = explode('/', $edgeId); if (count($parts) === 2) { list($collection, $edgeId) = $parts; } if ($collection === null) { $edgeCollections = $this->getEdgeCollections($graph); $edgeCollectionsCount = count($edgeCollections); if ($edgeCollectionsCount !== 1) { throw new ClientException('A collection must be provided.'); } if ($edgeCollectionsCount === 1) { $collection = $edgeCollections[0]; } } $params = $this->includeOptionsInParams( $options, [ 'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true, 'policy' => $this->getConnectionOption(ConnectionOptions::OPTION_DELETE_POLICY), ] ); if (null !== $revision) { $params[ConnectionOptions::OPTION_REVISION] = $revision; } $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
[ "public", "function", "removeEdge", "(", "$", "graph", ",", "$", "edgeId", ",", "$", "revision", "=", "null", ",", "array", "$", "options", "=", "[", "]", ",", "$", "collection", "=", "null", ")", "{", "if", "(", "$", "graph", "instanceof", "Graph", ...
Remove a edge from a graph, identified by the graph name and edge id<br><br> @throws Exception @param mixed $graph - graph name as a string or instance of Graph @param mixed $edgeId - edge id as string or number @param mixed $revision - optional revision of the edge to be deleted @param mixed $options optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method) <p> <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li> <li><b>waitForSync</b> - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li> </p> @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection @return bool - always true, will throw if there is an error @since 1.2
[ "Remove", "a", "edge", "from", "a", "graph", "identified", "by", "the", "graph", "name", "and", "edge", "id<br", ">", "<br", ">" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/GraphHandler.php#L1356-L1394
arangodb/arangodb-php
lib/ArangoDBClient/HttpResponse.php
HttpResponse.getHeader
public function getHeader($name) { assert(is_string($name)); $name = strtolower($name); if (isset($this->_headers[$name])) { return $this->_headers[$name]; } return null; }
php
public function getHeader($name) { assert(is_string($name)); $name = strtolower($name); if (isset($this->_headers[$name])) { return $this->_headers[$name]; } return null; }
[ "public", "function", "getHeader", "(", "$", "name", ")", "{", "assert", "(", "is_string", "(", "$", "name", ")", ")", ";", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_headers", "[", "...
Return an individual HTTP headers of the response @param string $name - name of header @return string - header value, NULL if header wasn't set in response
[ "Return", "an", "individual", "HTTP", "headers", "of", "the", "response" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/HttpResponse.php#L140-L151
arangodb/arangodb-php
lib/ArangoDBClient/HttpResponse.php
HttpResponse.getJson
public function getJson() { $body = $this->getBody(); $json = json_decode($body, true); if (!is_array($json)) { if ($this->_wasAsync) { return []; } // should be an array, fail otherwise throw new ClientException('Got a malformed result from the server'); } return $json; }
php
public function getJson() { $body = $this->getBody(); $json = json_decode($body, true); if (!is_array($json)) { if ($this->_wasAsync) { return []; } // should be an array, fail otherwise throw new ClientException('Got a malformed result from the server'); } return $json; }
[ "public", "function", "getJson", "(", ")", "{", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ";", "$", "json", "=", "json_decode", "(", "$", "body", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "json", ")", ")", "{"...
Return the data from the JSON-encoded body @throws ClientException @return array - array of values from the JSON-encoded response body
[ "Return", "the", "data", "from", "the", "JSON", "-", "encoded", "body" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/HttpResponse.php#L209-L224
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.createFromArray
public static function createFromArray(array $values) { $collection = new self(); foreach ($values as $key => $value) { $collection->set($key, $value); } return $collection; }
php
public static function createFromArray(array $values) { $collection = new self(); foreach ($values as $key => $value) { $collection->set($key, $value); } return $collection; }
[ "public", "static", "function", "createFromArray", "(", "array", "$", "values", ")", "{", "$", "collection", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "collection", "->", "s...
Factory method to construct a new collection @throws ClientException @param array $values - initial values for collection @return Collection
[ "Factory", "method", "to", "construct", "a", "new", "collection" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L242-L251
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.getAll
public function getAll() { $result = [ self::ENTRY_ID => $this->_id, self::ENTRY_NAME => $this->_name, self::ENTRY_WAIT_SYNC => $this->_waitForSync, self::ENTRY_JOURNAL_SIZE => $this->_journalSize, self::ENTRY_IS_SYSTEM => $this->_isSystem, self::ENTRY_IS_VOLATILE => $this->_isVolatile, self::ENTRY_TYPE => $this->_type, self::ENTRY_STATUS => $this->_status, self::ENTRY_KEY_OPTIONS => $this->_keyOptions ]; if (null !== $this->_numberOfShards) { $result[self::ENTRY_NUMBER_OF_SHARDS] = $this->_numberOfShards; } if (null !== $this->_replicationFactor) { $result[self::ENTRY_REPLICATION_FACTOR] = $this->_replicationFactor; } if (null !== $this->_shardingStrategy) { $result[self::ENTRY_SHARDING_STRATEGY] = $this->_shardingStrategy; } if (is_array($this->_shardKeys)) { $result[self::ENTRY_SHARD_KEYS] = $this->_shardKeys; } return $result; }
php
public function getAll() { $result = [ self::ENTRY_ID => $this->_id, self::ENTRY_NAME => $this->_name, self::ENTRY_WAIT_SYNC => $this->_waitForSync, self::ENTRY_JOURNAL_SIZE => $this->_journalSize, self::ENTRY_IS_SYSTEM => $this->_isSystem, self::ENTRY_IS_VOLATILE => $this->_isVolatile, self::ENTRY_TYPE => $this->_type, self::ENTRY_STATUS => $this->_status, self::ENTRY_KEY_OPTIONS => $this->_keyOptions ]; if (null !== $this->_numberOfShards) { $result[self::ENTRY_NUMBER_OF_SHARDS] = $this->_numberOfShards; } if (null !== $this->_replicationFactor) { $result[self::ENTRY_REPLICATION_FACTOR] = $this->_replicationFactor; } if (null !== $this->_shardingStrategy) { $result[self::ENTRY_SHARDING_STRATEGY] = $this->_shardingStrategy; } if (is_array($this->_shardKeys)) { $result[self::ENTRY_SHARD_KEYS] = $this->_shardKeys; } return $result; }
[ "public", "function", "getAll", "(", ")", "{", "$", "result", "=", "[", "self", "::", "ENTRY_ID", "=>", "$", "this", "->", "_id", ",", "self", "::", "ENTRY_NAME", "=>", "$", "this", "->", "_name", ",", "self", "::", "ENTRY_WAIT_SYNC", "=>", "$", "thi...
Get all collection attributes @return array - array of all collection attributes
[ "Get", "all", "collection", "attributes" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L325-L356
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.set
public function set($key, $value) { if (!is_string($key)) { throw new ClientException('Invalid collection attribute type'); } if ($key === self::ENTRY_ID) { $this->setId($value); return; } if ($key === self::ENTRY_NAME) { $this->setName($value); return; } if ($key === self::ENTRY_WAIT_SYNC) { $this->setWaitForSync($value); return; } if ($key === self::ENTRY_JOURNAL_SIZE) { $this->setJournalSize($value); return; } if ($key === self::ENTRY_IS_SYSTEM) { $this->setIsSystem($value); return; } if ($key === self::ENTRY_IS_VOLATILE) { $this->setIsVolatile($value); return; } if ($key === self::ENTRY_TYPE) { $this->setType($value); return; } if ($key === self::ENTRY_STATUS) { $this->setStatus($value); return; } if ($key === self::ENTRY_KEY_OPTIONS) { $this->setKeyOptions($value); return; } if ($key === self::ENTRY_NUMBER_OF_SHARDS) { $this->setNumberOfShards($value); return; } if ($key === self::ENTRY_REPLICATION_FACTOR) { $this->setReplicationFactor($value); return; } if ($key === self::ENTRY_SHARDING_STRATEGY) { $this->setShardingStrategy($value); return; } if ($key === self::ENTRY_SHARD_KEYS) { $this->setShardKeys($value); return; } // unknown attribute, will be ignored }
php
public function set($key, $value) { if (!is_string($key)) { throw new ClientException('Invalid collection attribute type'); } if ($key === self::ENTRY_ID) { $this->setId($value); return; } if ($key === self::ENTRY_NAME) { $this->setName($value); return; } if ($key === self::ENTRY_WAIT_SYNC) { $this->setWaitForSync($value); return; } if ($key === self::ENTRY_JOURNAL_SIZE) { $this->setJournalSize($value); return; } if ($key === self::ENTRY_IS_SYSTEM) { $this->setIsSystem($value); return; } if ($key === self::ENTRY_IS_VOLATILE) { $this->setIsVolatile($value); return; } if ($key === self::ENTRY_TYPE) { $this->setType($value); return; } if ($key === self::ENTRY_STATUS) { $this->setStatus($value); return; } if ($key === self::ENTRY_KEY_OPTIONS) { $this->setKeyOptions($value); return; } if ($key === self::ENTRY_NUMBER_OF_SHARDS) { $this->setNumberOfShards($value); return; } if ($key === self::ENTRY_REPLICATION_FACTOR) { $this->setReplicationFactor($value); return; } if ($key === self::ENTRY_SHARDING_STRATEGY) { $this->setShardingStrategy($value); return; } if ($key === self::ENTRY_SHARD_KEYS) { $this->setShardKeys($value); return; } // unknown attribute, will be ignored }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "ClientException", "(", "'Invalid collection attribute type'", ")", ";", "}", "if", "(", "$", "key",...
Set a collection attribute The key (attribute name) must be a string. This will validate the value of the attribute and might throw an exception if the value is invalid. @throws ClientException @param string $key - attribute name @param mixed $value - value for attribute @return void
[ "Set", "a", "collection", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L373-L457
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setId
public function setId($id) { if ($this->_id !== null && $this->_id !== $id) { throw new ClientException('Should not update the id of an existing collection'); } return $this->_id = (string) $id; }
php
public function setId($id) { if ($this->_id !== null && $this->_id !== $id) { throw new ClientException('Should not update the id of an existing collection'); } return $this->_id = (string) $id; }
[ "public", "function", "setId", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "_id", "!==", "null", "&&", "$", "this", "->", "_id", "!==", "$", "id", ")", "{", "throw", "new", "ClientException", "(", "'Should not update the id of an existing colle...
Set the collection id This will throw if the id of an existing collection gets updated to some other id @throws ClientException @param mixed $id - collection id @return bool
[ "Set", "the", "collection", "id" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L470-L477
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setName
public function setName($name) { assert(is_string($name)); if ($this->_name !== null && $this->_name !== $name) { throw new ClientException('Should not update the name of an existing collection'); } $this->_name = (string) $name; }
php
public function setName($name) { assert(is_string($name)); if ($this->_name !== null && $this->_name !== $name) { throw new ClientException('Should not update the name of an existing collection'); } $this->_name = (string) $name; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "assert", "(", "is_string", "(", "$", "name", ")", ")", ";", "if", "(", "$", "this", "->", "_name", "!==", "null", "&&", "$", "this", "->", "_name", "!==", "$", "name", ")", "{", "throw...
Set the collection name @throws ClientException @param string $name - name @return void
[ "Set", "the", "collection", "name" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L503-L512
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setType
public function setType($type) { if ($type === 'document') { $type = self::TYPE_DOCUMENT; } else if ($type === 'edge') { $type = self::TYPE_EDGE; } if ($this->_type !== null && $this->_type !== $type) { throw new ClientException('Should not update the type of an existing collection'); } if ($type !== self::TYPE_DOCUMENT && $type !== self::TYPE_EDGE) { throw new ClientException('Invalid type used for collection'); } assert(is_int($type)); $this->_type = $type; }
php
public function setType($type) { if ($type === 'document') { $type = self::TYPE_DOCUMENT; } else if ($type === 'edge') { $type = self::TYPE_EDGE; } if ($this->_type !== null && $this->_type !== $type) { throw new ClientException('Should not update the type of an existing collection'); } if ($type !== self::TYPE_DOCUMENT && $type !== self::TYPE_EDGE) { throw new ClientException('Invalid type used for collection'); } assert(is_int($type)); $this->_type = $type; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "$", "type", "===", "'document'", ")", "{", "$", "type", "=", "self", "::", "TYPE_DOCUMENT", ";", "}", "else", "if", "(", "$", "type", "===", "'edge'", ")", "{", "$", "type", ...
Set the collection type. This is useful before a collection is create() 'ed in order to set a different type than the normal one. For example this must be set to 3 in order to create an edge-collection. @throws ClientException @param int $type - type = 2 -> normal collection, type = 3 -> edge-collection @return void
[ "Set", "the", "collection", "type", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L536-L554
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setStatus
public function setStatus($status) { assert(is_int($status)); if ($this->_status !== null && $this->_status !== $status) { throw new ClientException('Should not update the status of an existing collection'); } if (!in_array( $status, [ self::STATUS_NEW_BORN, self::STATUS_UNLOADED, self::STATUS_LOADED, self::STATUS_BEING_UNLOADED, self::STATUS_DELETED ], true ) ) { throw new ClientException('Invalid status used for collection'); } $this->_status = $status; }
php
public function setStatus($status) { assert(is_int($status)); if ($this->_status !== null && $this->_status !== $status) { throw new ClientException('Should not update the status of an existing collection'); } if (!in_array( $status, [ self::STATUS_NEW_BORN, self::STATUS_UNLOADED, self::STATUS_LOADED, self::STATUS_BEING_UNLOADED, self::STATUS_DELETED ], true ) ) { throw new ClientException('Invalid status used for collection'); } $this->_status = $status; }
[ "public", "function", "setStatus", "(", "$", "status", ")", "{", "assert", "(", "is_int", "(", "$", "status", ")", ")", ";", "if", "(", "$", "this", "->", "_status", "!==", "null", "&&", "$", "this", "->", "_status", "!==", "$", "status", ")", "{",...
Set the collection status. This is useful before a collection is create()'ed in order to set a status. @throws ClientException @param int $status - statuses = 1 -> new born, status = 2 -> unloaded, status = 3 -> loaded, status = 4 -> being unloaded, status = 5 -> deleted @return void
[ "Set", "the", "collection", "status", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L577-L600
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setWaitForSync
public function setWaitForSync($value) { assert(null === $value || is_bool($value)); $this->_waitForSync = $value; }
php
public function setWaitForSync($value) { assert(null === $value || is_bool($value)); $this->_waitForSync = $value; }
[ "public", "function", "setWaitForSync", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_bool", "(", "$", "value", ")", ")", ";", "$", "this", "->", "_waitForSync", "=", "$", "value", ";", "}" ]
Set the waitForSync value @param bool $value - waitForSync value @return void
[ "Set", "the", "waitForSync", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L645-L649
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setIsSystem
public function setIsSystem($value) { assert(null === $value || is_bool($value)); $this->_isSystem = $value; }
php
public function setIsSystem($value) { assert(null === $value || is_bool($value)); $this->_isSystem = $value; }
[ "public", "function", "setIsSystem", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_bool", "(", "$", "value", ")", ")", ";", "$", "this", "->", "_isSystem", "=", "$", "value", ";", "}" ]
Set the isSystem value @param bool $value - isSystem: false->user collection, true->system collection @return void
[ "Set", "the", "isSystem", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L691-L695
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setIsVolatile
public function setIsVolatile($value) { assert(null === $value || is_bool($value)); $this->_isVolatile = $value; }
php
public function setIsVolatile($value) { assert(null === $value || is_bool($value)); $this->_isVolatile = $value; }
[ "public", "function", "setIsVolatile", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_bool", "(", "$", "value", ")", ")", ";", "$", "this", "->", "_isVolatile", "=", "$", "value", ";", "}" ]
Set the isVolatile value @param bool $value - isVolatile value @return void
[ "Set", "the", "isVolatile", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L714-L718
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setNumberOfShards
public function setNumberOfShards($value) { assert(null === $value || is_numeric($value)); $this->_numberOfShards = $value; }
php
public function setNumberOfShards($value) { assert(null === $value || is_numeric($value)); $this->_numberOfShards = $value; }
[ "public", "function", "setNumberOfShards", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_numeric", "(", "$", "value", ")", ")", ";", "$", "this", "->", "_numberOfShards", "=", "$", "value", ";", "}" ]
Set the numberOfShards value @param int $value - numberOfShards value @return void
[ "Set", "the", "numberOfShards", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L737-L741
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setReplicationFactor
public function setReplicationFactor($value) { assert(null === $value || is_numeric($value) || $value === 'satellite'); $this->_replicationFactor = $value; }
php
public function setReplicationFactor($value) { assert(null === $value || is_numeric($value) || $value === 'satellite'); $this->_replicationFactor = $value; }
[ "public", "function", "setReplicationFactor", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_numeric", "(", "$", "value", ")", "||", "$", "value", "===", "'satellite'", ")", ";", "$", "this", "->", "_replicationFactor", ...
Set the replicationFactor value @param int $value - replicationFactor value @return void
[ "Set", "the", "replicationFactor", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L761-L765
arangodb/arangodb-php
lib/ArangoDBClient/Collection.php
Collection.setShardKeys
public function setShardKeys($value) { assert(null === $value || is_array($value)); $this->_shardKeys = $value; }
php
public function setShardKeys($value) { assert(null === $value || is_array($value)); $this->_shardKeys = $value; }
[ "public", "function", "setShardKeys", "(", "$", "value", ")", "{", "assert", "(", "null", "===", "$", "value", "||", "is_array", "(", "$", "value", ")", ")", ";", "$", "this", "->", "_shardKeys", "=", "$", "value", ";", "}" ]
Set the shardKeys value @param array $value - shardKeys value @return void
[ "Set", "the", "shardKeys", "value" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Collection.php#L806-L810
arangodb/arangodb-php
lib/ArangoDBClient/Handler.php
Handler.includeOptionsInParams
protected function includeOptionsInParams($options, array $includeArray = []) { $params = []; foreach ($options as $key => $value) { if (array_key_exists($key, $includeArray)) { if ($key === ConnectionOptions::OPTION_UPDATE_POLICY) { UpdatePolicy::validate($value); } $params[$key] = $value; if ($value === null) { $params[$key] = $includeArray[$key]; } } } foreach ($includeArray as $key => $value) { if (!array_key_exists($key, $options)) { if ($key === ConnectionOptions::OPTION_UPDATE_POLICY) { UpdatePolicy::validate($value); } if ($value !== null) { $params[$key] = $value; } } } return $params; }
php
protected function includeOptionsInParams($options, array $includeArray = []) { $params = []; foreach ($options as $key => $value) { if (array_key_exists($key, $includeArray)) { if ($key === ConnectionOptions::OPTION_UPDATE_POLICY) { UpdatePolicy::validate($value); } $params[$key] = $value; if ($value === null) { $params[$key] = $includeArray[$key]; } } } foreach ($includeArray as $key => $value) { if (!array_key_exists($key, $options)) { if ($key === ConnectionOptions::OPTION_UPDATE_POLICY) { UpdatePolicy::validate($value); } if ($value !== null) { $params[$key] = $value; } } } return $params; }
[ "protected", "function", "includeOptionsInParams", "(", "$", "options", ",", "array", "$", "includeArray", "=", "[", "]", ")", "{", "$", "params", "=", "[", "]", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if...
Helper function that runs through the options given and includes them into the parameters array given. Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in form of url parameters (like 'waitForSync', 'keepNull', etc...) . @param array $options - The options array that holds the options to include in the parameters @param array $includeArray - The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true @return array $params - array of parameters for use in a url @throws \ArangoDBClient\ClientException @internal param array $params - The parameters into which the options will be included.
[ "Helper", "function", "that", "runs", "through", "the", "options", "given", "and", "includes", "them", "into", "the", "parameters", "array", "given", ".", "Only", "options", "that", "are", "set", "in", "$includeArray", "will", "be", "included", ".", "This", ...
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Handler.php#L99-L127
arangodb/arangodb-php
lib/ArangoDBClient/Handler.php
Handler.includeOptionsInBody
protected function includeOptionsInBody($options, $body, array $includeArray = []) { foreach ($options as $key => $value) { if (array_key_exists($key, $includeArray)) { $body[$key] = $value; if ($value === null && $includeArray[$key] !== null) { $body[$key] = $includeArray[$key]; } } } return $body; }
php
protected function includeOptionsInBody($options, $body, array $includeArray = []) { foreach ($options as $key => $value) { if (array_key_exists($key, $includeArray)) { $body[$key] = $value; if ($value === null && $includeArray[$key] !== null) { $body[$key] = $includeArray[$key]; } } } return $body; }
[ "protected", "function", "includeOptionsInBody", "(", "$", "options", ",", "$", "body", ",", "array", "$", "includeArray", "=", "[", "]", ")", "{", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_ex...
Helper function that runs through the options given and includes them into the parameters array given. Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in a json body(like 'limit', 'skip', etc...) . @param array $options - The options array that holds the options to include in the parameters @param array $body - The array into which the options will be included. @param array $includeArray - The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true @return array $params - array of parameters for use in a url
[ "Helper", "function", "that", "runs", "through", "the", "options", "given", "and", "includes", "them", "into", "the", "parameters", "array", "given", ".", "Only", "options", "that", "are", "set", "in", "$includeArray", "will", "be", "included", ".", "This", ...
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Handler.php#L142-L154
arangodb/arangodb-php
lib/ArangoDBClient/Handler.php
Handler.makeCollection
protected function makeCollection($value) { if ($value instanceof Collection) { return $value->getName(); } if ($value instanceof Document) { return $value->getCollectionId(); } return $value; }
php
protected function makeCollection($value) { if ($value instanceof Collection) { return $value->getName(); } if ($value instanceof Document) { return $value->getCollectionId(); } return $value; }
[ "protected", "function", "makeCollection", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Collection", ")", "{", "return", "$", "value", "->", "getName", "(", ")", ";", "}", "if", "(", "$", "value", "instanceof", "Document", ")", ...
Turn a value into a collection name @throws ClientException @param mixed $value - document, collection or string @return string - collection name
[ "Turn", "a", "value", "into", "a", "collection", "name" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Handler.php#L165-L175
arangodb/arangodb-php
lib/ArangoDBClient/UpdatePolicy.php
UpdatePolicy.validate
public static function validate($value) { assert(is_string($value)); if ($value !== self::LAST && $value !== self::ERROR) { throw new ClientException('Invalid update policy'); } }
php
public static function validate($value) { assert(is_string($value)); if ($value !== self::LAST && $value !== self::ERROR) { throw new ClientException('Invalid update policy'); } }
[ "public", "static", "function", "validate", "(", "$", "value", ")", "{", "assert", "(", "is_string", "(", "$", "value", ")", ")", ";", "if", "(", "$", "value", "!==", "self", "::", "LAST", "&&", "$", "value", "!==", "self", "::", "ERROR", ")", "{",...
Check if the supplied policy value is valid @throws ClientException @param string $value - update policy value @return void
[ "Check", "if", "the", "supplied", "policy", "value", "is", "valid" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UpdatePolicy.php#L40-L47
arangodb/arangodb-php
lib/ArangoDBClient/Autoloader.php
Autoloader.load
public static function load($className) { $namespace = __NAMESPACE__ . '\\'; $length = strlen($namespace); // if (substr($className, 0, $length) !== $namespace) { if (0 !== strpos($className, $namespace)) { return; } // init() must have been called before assert(self::$libDir !== null); require self::$libDir . substr($className, $length) . self::EXTENSION; }
php
public static function load($className) { $namespace = __NAMESPACE__ . '\\'; $length = strlen($namespace); // if (substr($className, 0, $length) !== $namespace) { if (0 !== strpos($className, $namespace)) { return; } // init() must have been called before assert(self::$libDir !== null); require self::$libDir . substr($className, $length) . self::EXTENSION; }
[ "public", "static", "function", "load", "(", "$", "className", ")", "{", "$", "namespace", "=", "__NAMESPACE__", ".", "'\\\\'", ";", "$", "length", "=", "strlen", "(", "$", "namespace", ")", ";", "// if (substr($className, 0, $length) !== $namespace) {", "i...
Handle loading of an unknown class This will only handle class from its own namespace and ignore all others. This allows multiple autoloaders to be used in a nested fashion. @param string $className - name of class to be loaded @return void
[ "Handle", "loading", "of", "an", "unknown", "class" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Autoloader.php#L63-L77
arangodb/arangodb-php
lib/ArangoDBClient/Autoloader.php
Autoloader.checkEnvironment
private static function checkEnvironment() { list($major, $minor) = explode('.', PHP_VERSION); if ((int) $major < 5 || ((int) $major === 5 && (int) $minor < 6)) { throw new ClientException('Incompatible PHP environment. Expecting PHP 5.6 or higher'); } }
php
private static function checkEnvironment() { list($major, $minor) = explode('.', PHP_VERSION); if ((int) $major < 5 || ((int) $major === 5 && (int) $minor < 6)) { throw new ClientException('Incompatible PHP environment. Expecting PHP 5.6 or higher'); } }
[ "private", "static", "function", "checkEnvironment", "(", ")", "{", "list", "(", "$", "major", ",", "$", "minor", ")", "=", "explode", "(", "'.'", ",", "PHP_VERSION", ")", ";", "if", "(", "(", "int", ")", "$", "major", "<", "5", "||", "(", "(", "...
Check the runtime environment This will check whether the runtime environment is compatible with the Arango PHP client. @throws ClientException @return void
[ "Check", "the", "runtime", "environment" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Autoloader.php#L88-L95
arangodb/arangodb-php
lib/ArangoDBClient/FoxxHandler.php
FoxxHandler.installFoxxZip
public function installFoxxZip($localZip, $mountPoint, array $options = []) { if (!file_exists($localZip)) { throw new ClientException("Foxx-Zip {$localZip} does not exist (or file is unreadable)."); } try { $post = file_get_contents($localZip); $response = $this->getConnection()->post(Urls::URL_UPLOAD, $post); if ($response->getHttpCode() < 400) { $response = $this->getConnection()->put(Urls::URL_FOXX_INSTALL, json_encode(['appInfo' => $response->getJson()['filename'], 'mount' => $mountPoint])); if ($response->getHttpCode() < 400) { return $response->getJson(); } throw new ClientException('Foxx-Zip install failed'); } throw new ClientException('Foxx-Zip upload failed'); } catch (ServerException $e) { throw new ClientException($e->getMessage()); } }
php
public function installFoxxZip($localZip, $mountPoint, array $options = []) { if (!file_exists($localZip)) { throw new ClientException("Foxx-Zip {$localZip} does not exist (or file is unreadable)."); } try { $post = file_get_contents($localZip); $response = $this->getConnection()->post(Urls::URL_UPLOAD, $post); if ($response->getHttpCode() < 400) { $response = $this->getConnection()->put(Urls::URL_FOXX_INSTALL, json_encode(['appInfo' => $response->getJson()['filename'], 'mount' => $mountPoint])); if ($response->getHttpCode() < 400) { return $response->getJson(); } throw new ClientException('Foxx-Zip install failed'); } throw new ClientException('Foxx-Zip upload failed'); } catch (ServerException $e) { throw new ClientException($e->getMessage()); } }
[ "public", "function", "installFoxxZip", "(", "$", "localZip", ",", "$", "mountPoint", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "file_exists", "(", "$", "localZip", ")", ")", "{", "throw", "new", "ClientException", "(", "\"...
Upload and install a foxx app. @throws ClientException @param string $localZip - the path to the local foxx-app zip-archive to upload/install @param string $mountPoint - the mount-point for the app, must begin with a '/' @param array $options - for future usage @return array - the server response @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Upload", "and", "install", "a", "foxx", "app", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/FoxxHandler.php#L34-L57
arangodb/arangodb-php
lib/ArangoDBClient/FoxxHandler.php
FoxxHandler.removeFoxxApp
public function removeFoxxApp($mountPoint, array $options = []) { try { $response = $this->getConnection()->put(Urls::URL_FOXX_UNINSTALL, json_encode(['mount' => $mountPoint])); if ($response->getHttpCode() < 400) { return $response->getJson(); } throw new ClientException(sprintf('Foxx uninstall failed (Code: %d)', $response->getHttpCode())); } catch (ServerException $e) { if ($e->getMessage() === 'Service not found') { throw new ClientException(sprintf('Mount point %s not present.', $mountPoint)); } throw new ClientException($e->getMessage()); } }
php
public function removeFoxxApp($mountPoint, array $options = []) { try { $response = $this->getConnection()->put(Urls::URL_FOXX_UNINSTALL, json_encode(['mount' => $mountPoint])); if ($response->getHttpCode() < 400) { return $response->getJson(); } throw new ClientException(sprintf('Foxx uninstall failed (Code: %d)', $response->getHttpCode())); } catch (ServerException $e) { if ($e->getMessage() === 'Service not found') { throw new ClientException(sprintf('Mount point %s not present.', $mountPoint)); } throw new ClientException($e->getMessage()); } }
[ "public", "function", "removeFoxxApp", "(", "$", "mountPoint", ",", "array", "$", "options", "=", "[", "]", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "getConnection", "(", ")", "->", "put", "(", "Urls", "::", "URL_FOXX_UNINSTALL", ...
Remove a foxx-app. @throws ClientException @param string $mountPoint - the mount-point for the app, must begin with a '/' @param array $options - for future usage @return array - the server response @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Remove", "a", "foxx", "-", "app", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/FoxxHandler.php#L71-L86
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.addUser
public function addUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->user = $username; $userDocument->passwd = $passwd; $userDocument->active = $active; $userDocument->extra = $extra; $data = $userDocument->getAll(); $this->getConnection()->post(Urls::URL_USER, $this->json_encode_wrapper($data)); try { // additionally set user permissions in the current databases $this->grantPermissions($username, $this->getConnection()->getDatabase()); } catch (\Exception $e) { } return true; }
php
public function addUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->user = $username; $userDocument->passwd = $passwd; $userDocument->active = $active; $userDocument->extra = $extra; $data = $userDocument->getAll(); $this->getConnection()->post(Urls::URL_USER, $this->json_encode_wrapper($data)); try { // additionally set user permissions in the current databases $this->grantPermissions($username, $this->getConnection()->getDatabase()); } catch (\Exception $e) { } return true; }
[ "public", "function", "addUser", "(", "$", "username", ",", "$", "passwd", "=", "null", ",", "$", "active", "=", "null", ",", "$", "extra", "=", "null", ")", "{", "$", "userDocument", "=", "new", "User", "(", ")", ";", "$", "userDocument", "->", "u...
save a user to the user-collection This will save the user to the users collection. It will additionally grant the user permissions for the current database This will throw if the user cannot be saved @throws Exception @param string $username - The name of the user as a string. This is mandatory. @param mixed $passwd - The user password as a string. If no password is specified, the empty string will be used. @param mixed $active - an optional flag that specifies whether the user is active. If not specified, this will default to true. @param array $extra - an optional array with arbitrary extra data about the user. @return boolean - true, if user could be saved @since 1.2
[ "save", "a", "user", "to", "the", "user", "-", "collection" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L44-L62
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.replaceUser
public function replaceUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->passwd = $passwd; $userDocument->active = $active; $userDocument->extra = $extra; $data = $userDocument->getAll(); $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $this->getConnection()->put($url, $this->json_encode_wrapper($data)); return true; }
php
public function replaceUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->passwd = $passwd; $userDocument->active = $active; $userDocument->extra = $extra; $data = $userDocument->getAll(); $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $this->getConnection()->put($url, $this->json_encode_wrapper($data)); return true; }
[ "public", "function", "replaceUser", "(", "$", "username", ",", "$", "passwd", "=", "null", ",", "$", "active", "=", "null", ",", "$", "extra", "=", "null", ")", "{", "$", "userDocument", "=", "new", "User", "(", ")", ";", "$", "userDocument", "->", ...
Replace an existing user, identified by its username This will replace the user-document on the server This will throw if the document cannot be replaced @throws Exception @param string $username - The name of the user as a string, who's user-data is going to be replaced. This is mandatory. @param mixed $passwd - The user password as a string. If no password is specified, the empty string will be used. @param mixed $active - an optional flag that specifies whether the user is active. If not specified, this will default to true. @param array $extra - an optional array with arbitrary extra data about the user. @return bool - always true, will throw if there is an error
[ "Replace", "an", "existing", "user", "identified", "by", "its", "username" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L80-L91
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.updateUser
public function updateUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->active = $active; if (null !== $passwd) { $userDocument->passwd = $passwd; } if (null !== $active) { $userDocument->active = $active; } if (null !== $extra) { $userDocument->extra = $extra; } $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $this->getConnection()->patch($url, $this->json_encode_wrapper($userDocument->getAll())); return true; }
php
public function updateUser($username, $passwd = null, $active = null, $extra = null) { $userDocument = new User(); $userDocument->active = $active; if (null !== $passwd) { $userDocument->passwd = $passwd; } if (null !== $active) { $userDocument->active = $active; } if (null !== $extra) { $userDocument->extra = $extra; } $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $this->getConnection()->patch($url, $this->json_encode_wrapper($userDocument->getAll())); return true; }
[ "public", "function", "updateUser", "(", "$", "username", ",", "$", "passwd", "=", "null", ",", "$", "active", "=", "null", ",", "$", "extra", "=", "null", ")", "{", "$", "userDocument", "=", "new", "User", "(", ")", ";", "$", "userDocument", "->", ...
Update an existing user, identified by the username This will update the user-document on the server This will throw if the document cannot be updated @throws Exception @param string $username - The name of the user as a string, who's user-data is going to be updated. This is mandatory. @param mixed $passwd - The user password as a string. If no password is specified, the empty string will be used. @param mixed $active - an optional flag that specifies whether the user is active. If not specified, this will default to true. @param array $extra - an optional array with arbitrary extra data about the user. @return bool - always true, will throw if there is an error
[ "Update", "an", "existing", "user", "identified", "by", "the", "username" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L110-L128
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.get
public function get($username) { $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $response = $this->getConnection()->get($url); $data = $response->getJson(); $options = ['_isNew' => false]; $_documentClass = $this->_documentClass; return $_documentClass::createFromArray($data, $options); }
php
public function get($username) { $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $response = $this->getConnection()->get($url); $data = $response->getJson(); $options = ['_isNew' => false]; $_documentClass = $this->_documentClass; return $_documentClass::createFromArray($data, $options); }
[ "public", "function", "get", "(", "$", "username", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_USER", ",", "[", "$", "username", "]", ")", ";", "$", "response", "=", "$", "this", "->", "getConnection", "(", ")", ...
Get a single user-document, identified by the username This will throw if the document cannot be fetched from the server @throws Exception @param string $username - username as a string @return User - the user-document fetched from the server
[ "Get", "a", "single", "user", "-", "document", "identified", "by", "the", "username" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L142-L153
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.removeUser
public function removeUser($username) { // This preserves compatibility for the old policy parameter. $params = []; $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
php
public function removeUser($username) { // This preserves compatibility for the old policy parameter. $params = []; $url = UrlHelper::buildUrl(Urls::URL_USER, [$username]); $url = UrlHelper::appendParamsUrl($url, $params); $this->getConnection()->delete($url); return true; }
[ "public", "function", "removeUser", "(", "$", "username", ")", "{", "// This preserves compatibility for the old policy parameter.", "$", "params", "=", "[", "]", ";", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_USER", ",", "[", "$", ...
Remove a user, identified by the username @throws Exception @param string $username - username as a string, of the user that is to be deleted @return bool - always true, will throw if there is an error
[ "Remove", "a", "user", "identified", "by", "the", "username" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L165-L175
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.grantDatabasePermissions
public function grantDatabasePermissions($username, $databaseName, $permissions = 'rw') { $data = [ 'grant' => $permissions ]; $url = UrlHelper::buildUrl(Urls::URL_USER, [$username, 'database', $databaseName]); $this->getConnection()->put($url, $this->json_encode_wrapper($data)); return true; }
php
public function grantDatabasePermissions($username, $databaseName, $permissions = 'rw') { $data = [ 'grant' => $permissions ]; $url = UrlHelper::buildUrl(Urls::URL_USER, [$username, 'database', $databaseName]); $this->getConnection()->put($url, $this->json_encode_wrapper($data)); return true; }
[ "public", "function", "grantDatabasePermissions", "(", "$", "username", ",", "$", "databaseName", ",", "$", "permissions", "=", "'rw'", ")", "{", "$", "data", "=", "[", "'grant'", "=>", "$", "permissions", "]", ";", "$", "url", "=", "UrlHelper", "::", "b...
Grant R/W permissions to a user, for a specific database @param string $username - username as a string @param string $databaseName - name of database as a string @param string $permissions - permissions string `rw` for read-write (default), `ro` for read-only @return bool
[ "Grant", "R", "/", "W", "permissions", "to", "a", "user", "for", "a", "specific", "database" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L206-L216
arangodb/arangodb-php
lib/ArangoDBClient/UserHandler.php
UserHandler.getDatabasePermissionLevel
public function getDatabasePermissionLevel($username, $databaseName) { $url = UrlHelper::buildUrl(Urls::URL_USER, [$username, 'database', $databaseName]); $response = $this->getConnection()->get($url); $data = $response->getJson(); return $data['result']; }
php
public function getDatabasePermissionLevel($username, $databaseName) { $url = UrlHelper::buildUrl(Urls::URL_USER, [$username, 'database', $databaseName]); $response = $this->getConnection()->get($url); $data = $response->getJson(); return $data['result']; }
[ "public", "function", "getDatabasePermissionLevel", "(", "$", "username", ",", "$", "databaseName", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_USER", ",", "[", "$", "username", ",", "'database'", ",", "$", "databaseName...
Gets the list of collections a user has access to @param string $username - username as a string @param string $databaseName - name of the database @return string
[ "Gets", "the", "list", "of", "collections", "a", "user", "has", "access", "to" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/UserHandler.php#L336-L344
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.register
public function register($name = null, $code = null) { $attributes = $this->attributes; if ($name) { $attributes['name'] = $name; } if ($code) { $attributes['code'] = $code; } $response = $this->_connection->post( Urls::URL_AQL_USER_FUNCTION, $this->getConnection()->json_encode_wrapper($attributes) ); return $response->getJson(); }
php
public function register($name = null, $code = null) { $attributes = $this->attributes; if ($name) { $attributes['name'] = $name; } if ($code) { $attributes['code'] = $code; } $response = $this->_connection->post( Urls::URL_AQL_USER_FUNCTION, $this->getConnection()->json_encode_wrapper($attributes) ); return $response->getJson(); }
[ "public", "function", "register", "(", "$", "name", "=", "null", ",", "$", "code", "=", "null", ")", "{", "$", "attributes", "=", "$", "this", "->", "attributes", ";", "if", "(", "$", "name", ")", "{", "$", "attributes", "[", "'name'", "]", "=", ...
Registers the user function If no parameters ($name,$code) are passed, it will use the properties of the object. If $name and/or $code are passed, it will override the object's properties with the passed ones @param null $name @param null $code @throws Exception throws exception if registration failed @return mixed true if registration was successful.
[ "Registers", "the", "user", "function" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L125-L144
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.unregister
public function unregister($name = null, $namespace = false) { if (null === $name) { $name = $this->getName(); } $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, [$name]); if ($namespace) { $url = UrlHelper::appendParamsUrl($url, ['group' => true]); } $response = $this->_connection->delete($url); return $response->getJson(); }
php
public function unregister($name = null, $namespace = false) { if (null === $name) { $name = $this->getName(); } $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, [$name]); if ($namespace) { $url = UrlHelper::appendParamsUrl($url, ['group' => true]); } $response = $this->_connection->delete($url); return $response->getJson(); }
[ "public", "function", "unregister", "(", "$", "name", "=", "null", ",", "$", "namespace", "=", "false", ")", "{", "if", "(", "null", "===", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "}", "$", "url", "...
Un-register the user function If no parameter ($name) is passed, it will use the property of the object. If $name is passed, it will override the object's property with the passed one @param string $name @param boolean $namespace @throws Exception throw exception if the request fails @return mixed true if successful without a return value or the return value if one was set in the action
[ "Un", "-", "register", "the", "user", "function" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L161-L176
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.getRegisteredUserFunctions
public function getRegisteredUserFunctions($namespace = null) { $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, []); if (null !== $namespace) { $url = UrlHelper::appendParamsUrl($url, ['namespace' => $namespace]); } $response = $this->_connection->get($url); $data = $response->getJson(); if (isset($data['result'])) { return $data['result']; } // backwards compatibility return $data; }
php
public function getRegisteredUserFunctions($namespace = null) { $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, []); if (null !== $namespace) { $url = UrlHelper::appendParamsUrl($url, ['namespace' => $namespace]); } $response = $this->_connection->get($url); $data = $response->getJson(); if (isset($data['result'])) { return $data['result']; } // backwards compatibility return $data; }
[ "public", "function", "getRegisteredUserFunctions", "(", "$", "namespace", "=", "null", ")", "{", "$", "url", "=", "UrlHelper", "::", "buildUrl", "(", "Urls", "::", "URL_AQL_USER_FUNCTION", ",", "[", "]", ")", ";", "if", "(", "null", "!==", "$", "namespace...
Get registered user functions The method can optionally be passed a $namespace parameter to narrow the results down to a specific namespace. @param null $namespace @throws Exception throw exception if the request failed @return mixed true if successful without a return value or the return value if one was set in the action
[ "Get", "registered", "user", "functions" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L190-L204
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.set
public function set($key, $value) { if (!is_string($key)) { throw new ClientException('Invalid attribute key'); } $this->attributes[$key] = $value; return $this; }
php
public function set($key, $value) { if (!is_string($key)) { throw new ClientException('Invalid attribute key'); } $this->attributes[$key] = $value; return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "ClientException", "(", "'Invalid attribute key'", ")", ";", "}", "$", "this", "->", "attributes", ...
Set an attribute @param $key @param $value @return $this @throws ClientException
[ "Set", "an", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L281-L290
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.get
public function get($key) { if (isset($this->attributes[$key])) { return $this->attributes[$key]; } return null; }
php
public function get($key) { if (isset($this->attributes[$key])) { return $this->attributes[$key]; } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "attributes", "[", "$", "key", "]", ";", "}", "return", "null", ...
Get an attribute @param string $key - name of attribute @return mixed - value of attribute, NULL if attribute is not set
[ "Get", "an", "attribute" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L328-L335
arangodb/arangodb-php
lib/ArangoDBClient/AqlUserFunction.php
AqlUserFunction.buildAttributesFromArray
public function buildAttributesFromArray($options) { if (isset($options[self::ENTRY_NAME])) { $this->setName($options[self::ENTRY_NAME]); } if (isset($options[self::ENTRY_CODE])) { $this->setCode($options[self::ENTRY_CODE]); } }
php
public function buildAttributesFromArray($options) { if (isset($options[self::ENTRY_NAME])) { $this->setName($options[self::ENTRY_NAME]); } if (isset($options[self::ENTRY_CODE])) { $this->setCode($options[self::ENTRY_CODE]); } }
[ "public", "function", "buildAttributesFromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "self", "::", "ENTRY_NAME", "]", ")", ")", "{", "$", "this", "->", "setName", "(", "$", "options", "[", "self", "::", "ENTRY_...
Build the object's attributes from a given array @param $options @throws \ArangoDBClient\ClientException
[ "Build", "the", "object", "s", "attributes", "from", "a", "given", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/AqlUserFunction.php#L389-L398
arangodb/arangodb-php
lib/ArangoDBClient/Export.php
Export.execute
public function execute() { $data = [ self::ENTRY_FLUSH => $this->_flush, self::ENTRY_COUNT => true ]; if ($this->_batchSize > 0) { $data[self::ENTRY_BATCHSIZE] = $this->_batchSize; } if ($this->_limit > 0) { $data[self::ENTRY_LIMIT] = $this->_limit; } if (is_array($this->_restrictions)) { $data[self::ENTRY_RESTRICT] = $this->_restrictions; } $collection = $this->_collection; if ($collection instanceof Collection) { $collection = $collection->getName(); } $url = UrlHelper::appendParamsUrl(Urls::URL_EXPORT, ['collection' => $collection]); $response = $this->_connection->post($url, $this->getConnection()->json_encode_wrapper($data)); return new ExportCursor($this->_connection, $response->getJson(), $this->getCursorOptions()); }
php
public function execute() { $data = [ self::ENTRY_FLUSH => $this->_flush, self::ENTRY_COUNT => true ]; if ($this->_batchSize > 0) { $data[self::ENTRY_BATCHSIZE] = $this->_batchSize; } if ($this->_limit > 0) { $data[self::ENTRY_LIMIT] = $this->_limit; } if (is_array($this->_restrictions)) { $data[self::ENTRY_RESTRICT] = $this->_restrictions; } $collection = $this->_collection; if ($collection instanceof Collection) { $collection = $collection->getName(); } $url = UrlHelper::appendParamsUrl(Urls::URL_EXPORT, ['collection' => $collection]); $response = $this->_connection->post($url, $this->getConnection()->json_encode_wrapper($data)); return new ExportCursor($this->_connection, $response->getJson(), $this->getCursorOptions()); }
[ "public", "function", "execute", "(", ")", "{", "$", "data", "=", "[", "self", "::", "ENTRY_FLUSH", "=>", "$", "this", "->", "_flush", ",", "self", "::", "ENTRY_COUNT", "=>", "true", "]", ";", "if", "(", "$", "this", "->", "_batchSize", ">", "0", "...
Execute the export This will return the results as a Cursor. The cursor can then be used to iterate the results. @throws Exception @return ExportCursor
[ "Execute", "the", "export" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Export.php#L191-L219
arangodb/arangodb-php
lib/ArangoDBClient/Export.php
Export.getCursorOptions
private function getCursorOptions() { $result = [ ExportCursor::ENTRY_FLAT => (bool) $this->_flat, ExportCursor::ENTRY_BASEURL => Urls::URL_EXPORT, ExportCursor::ENTRY_TYPE => $this->_type, '_documentClass' => $this->_documentClass, ]; return $result; }
php
private function getCursorOptions() { $result = [ ExportCursor::ENTRY_FLAT => (bool) $this->_flat, ExportCursor::ENTRY_BASEURL => Urls::URL_EXPORT, ExportCursor::ENTRY_TYPE => $this->_type, '_documentClass' => $this->_documentClass, ]; return $result; }
[ "private", "function", "getCursorOptions", "(", ")", "{", "$", "result", "=", "[", "ExportCursor", "::", "ENTRY_FLAT", "=>", "(", "bool", ")", "$", "this", "->", "_flat", ",", "ExportCursor", "::", "ENTRY_BASEURL", "=>", "Urls", "::", "URL_EXPORT", ",", "E...
Return an array of cursor options @return array - array of options
[ "Return", "an", "array", "of", "cursor", "options" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Export.php#L261-L271
arangodb/arangodb-php
lib/ArangoDBClient/Batch.php
Batch.stopCapture
public function stopCapture() { // check if this batch is the active one... and capturing. Ignore, if we're not capturing... if ($this->isActive() && $this->isCapturing()) { $this->setCapture(false); return $this; } throw new ClientException('Cannot stop capturing with this batch. Batch is not active...'); }
php
public function stopCapture() { // check if this batch is the active one... and capturing. Ignore, if we're not capturing... if ($this->isActive() && $this->isCapturing()) { $this->setCapture(false); return $this; } throw new ClientException('Cannot stop capturing with this batch. Batch is not active...'); }
[ "public", "function", "stopCapture", "(", ")", "{", "// check if this batch is the active one... and capturing. Ignore, if we're not capturing...", "if", "(", "$", "this", "->", "isActive", "(", ")", "&&", "$", "this", "->", "isCapturing", "(", ")", ")", "{", "$", "...
Stop capturing requests. If the batch has not been processed yet, more requests can be appended by calling startCapture() again. see Batch::startCapture() @throws ClientException @return Batch
[ "Stop", "capturing", "requests", ".", "If", "the", "batch", "has", "not", "been", "processed", "yet", "more", "requests", "can", "be", "appended", "by", "calling", "startCapture", "()", "again", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Batch.php#L168-L178
arangodb/arangodb-php
lib/ArangoDBClient/Batch.php
Batch.setBatchRequest
private function setBatchRequest($state) { $this->_connection->setBatchRequest($state); $this->_processed = true; return $this; }
php
private function setBatchRequest($state) { $this->_connection->setBatchRequest($state); $this->_processed = true; return $this; }
[ "private", "function", "setBatchRequest", "(", "$", "state", ")", "{", "$", "this", "->", "_connection", "->", "setBatchRequest", "(", "$", "state", ")", ";", "$", "this", "->", "_processed", "=", "true", ";", "return", "$", "this", ";", "}" ]
Sets connection into Batch-Request mode. This is necessary to distinguish between normal and the batch request. @param boolean $state @return $this
[ "Sets", "connection", "into", "Batch", "-", "Request", "mode", ".", "This", "is", "necessary", "to", "distinguish", "between", "normal", "and", "the", "batch", "request", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Batch.php#L282-L288