From c7ca1196c2331a8b3ace75c694ae9d1fbf32c2d3 Mon Sep 17 00:00:00 2001
From: F21
Date: Sun, 21 Apr 2013 11:53:06 +1000
Subject: [PATCH] Fixed formatting to psr2 standards.
---
examples/collection.php | 23 ++--
examples/document.php | 11 +-
examples/graph.php | 6 +-
examples/init.php | 1 -
examples/select.php | 17 +--
lib/triagens/ArangoDb/AdminHandler.php | 2 +-
lib/triagens/ArangoDb/Autoloader.php | 2 +-
lib/triagens/ArangoDb/BatchPart.php | 8 +-
lib/triagens/ArangoDb/CollectionHandler.php | 6 +-
lib/triagens/ArangoDb/Connection.php | 2 +-
lib/triagens/ArangoDb/Document.php | 78 +++++------
lib/triagens/ArangoDb/DocumentHandler.php | 84 ++++++------
lib/triagens/ArangoDb/EdgeHandler.php | 2 +-
lib/triagens/ArangoDb/Graph.php | 136 ++++++++++----------
lib/triagens/ArangoDb/GraphHandler.php | 60 ++++-----
lib/triagens/ArangoDb/HttpHelper.php | 2 +-
lib/triagens/ArangoDb/Statement.php | 14 +-
lib/triagens/ArangoDb/UrlHelper.php | 2 +-
lib/triagens/ArangoDb/Urls.php | 2 +-
lib/triagens/ArangoDb/UserHandler.php | 2 +-
lib/triagens/ArangoDb/VertexHandler.php | 2 +-
tests/BatchTest.php | 2 +-
tests/CollectionExtendedTest.php | 74 +++++------
tests/DocumentExtendedTest.php | 86 ++++++-------
tests/GraphBasicTest.php | 44 +++----
tests/GraphExtendedTest.php | 2 +-
tests/UserBasicTest.php | 3 +-
tests/bootstrap.php | 8 +-
28 files changed, 335 insertions(+), 346 deletions(-)
diff --git a/examples/collection.php b/examples/collection.php
index 57fe0c1e..a942c27a 100644
--- a/examples/collection.php
+++ b/examples/collection.php
@@ -7,13 +7,13 @@
try {
$connection = new Connection($connectionOptions);
$handler = new CollectionHandler($connection);
-
+
// create a new collection
$col = new Collection();
$col->setName("hihi");
$result = $handler->add($col);
var_dump($result);
-
+
// get an existing collection
$result = $handler->get("hihi");
var_dump($result);
@@ -21,31 +21,28 @@
// get an existing collection
$result = $handler->get("hihi");
var_dump($result);
-
+
// get number of documents from an existing collection
$result = $handler->getCount("hihi");
var_dump($result);
-
+
// get figures for an existing collection
$result = $handler->getFigures("hihi");
var_dump($result);
-
+
// delete the collection
$result = $handler->delete("hihi");
var_dump($result);
-
+
// rename a collection
// $handler->rename($col, "hihi30");
-
+
// truncate an existing collection
// $result = $handler->truncate("hihi");
-}
-catch (ConnectException $e) {
+} catch (ConnectException $e) {
print $e . PHP_EOL;
-}
-catch (ServerException $e) {
+} catch (ServerException $e) {
print $e . PHP_EOL;
-}
-catch (ClientException $e) {
+} catch (ClientException $e) {
print $e . PHP_EOL;
}
diff --git a/examples/document.php b/examples/document.php
index 34757a35..811246a8 100644
--- a/examples/document.php
+++ b/examples/document.php
@@ -42,7 +42,7 @@
unset($userFromServer->name);
$result = $handler->update($userFromServer);
var_dump($result);
-
+
// get the updated document back
$result = $handler->get("users", $id);
var_dump($result);
@@ -51,13 +51,10 @@
$result = $handler->deleteById("users", $id);
var_dump($result);
-}
-catch (ConnectException $e) {
+} catch (ConnectException $e) {
print $e . PHP_EOL;
-}
-catch (ServerException $e) {
+} catch (ServerException $e) {
print $e . PHP_EOL;
-}
-catch (ClientException $e) {
+} catch (ClientException $e) {
print $e . PHP_EOL;
}
diff --git a/examples/graph.php b/examples/graph.php
index dbb028ff..c94c84b6 100644
--- a/examples/graph.php
+++ b/examples/graph.php
@@ -54,10 +54,8 @@
$result1 = $graphHandler->removeEdge('Graph', 'edge1');
} catch (ConnectException $e) {
print $e . PHP_EOL;
-}
-catch (ServerException $e) {
+} catch (ServerException $e) {
print $e . PHP_EOL;
-}
-catch (ClientException $e) {
+} catch (ClientException $e) {
print $e . PHP_EOL;
}
diff --git a/examples/init.php b/examples/init.php
index 63030378..86845e6d 100644
--- a/examples/init.php
+++ b/examples/init.php
@@ -26,4 +26,3 @@
ConnectionOptions::OPTION_CREATE => false, // do not create unknown collections automatically
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST, // last update wins
);
-
diff --git a/examples/select.php b/examples/select.php
index 60c6fe71..bd78ab73 100644
--- a/examples/select.php
+++ b/examples/select.php
@@ -18,10 +18,10 @@
foreach ($statements as $query => $bindVars) {
$statement = new Statement($connection, array(
- "query" => $query,
- "count" => true,
- "batchSize" => 1000,
- "bindVars" => $bindVars,
+ "query" => $query,
+ "count" => true,
+ "batchSize" => 1000,
+ "bindVars" => $bindVars,
"sanitize" => true,
));
@@ -30,13 +30,10 @@
$cursor = $statement->execute();
var_dump($cursor->getAll());
}
-}
-catch (ConnectException $e) {
+} catch (ConnectException $e) {
print $e . PHP_EOL;
-}
-catch (ServerException $e) {
+} catch (ServerException $e) {
print $e . PHP_EOL;
-}
-catch (ClientException $e) {
+} catch (ClientException $e) {
print $e . PHP_EOL;
}
diff --git a/lib/triagens/ArangoDb/AdminHandler.php b/lib/triagens/ArangoDb/AdminHandler.php
index 3f24da25..5a7f6474 100644
--- a/lib/triagens/ArangoDb/AdminHandler.php
+++ b/lib/triagens/ArangoDb/AdminHandler.php
@@ -222,4 +222,4 @@ public function getServerRequestStatistics($options = array())
return $data;
}
-}
\ No newline at end of file
+}
diff --git a/lib/triagens/ArangoDb/Autoloader.php b/lib/triagens/ArangoDb/Autoloader.php
index 1be0882f..e69ae622 100644
--- a/lib/triagens/ArangoDb/Autoloader.php
+++ b/lib/triagens/ArangoDb/Autoloader.php
@@ -42,7 +42,7 @@ public static function init()
self::checkEnvironment();
self::$libDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
-
+
spl_autoload_register(__NAMESPACE__ . '\Autoloader::load');
}
diff --git a/lib/triagens/ArangoDb/BatchPart.php b/lib/triagens/ArangoDb/BatchPart.php
index c54bc1ae..4fcb1a50 100644
--- a/lib/triagens/ArangoDb/BatchPart.php
+++ b/lib/triagens/ArangoDb/BatchPart.php
@@ -260,7 +260,7 @@ public function getProcessedResponse()
$json = $response->getJson();
$id = $json[Edge::ENTRY_ID];
$response = $json;
- $options = $this->getCursorOptions();
+ $options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Edge::createFromArray($json, $options);
break;
@@ -275,7 +275,7 @@ public function getProcessedResponse()
$json = $response->getJson();
$id = $json[Collection::ENTRY_ID];
$response = $json;
- $options = $this->getCursorOptions();
+ $options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Collection::createFromArray($json, $options);
break;
@@ -287,7 +287,7 @@ public function getProcessedResponse()
}
break;
case 'cursor':
- $options = $this->getCursorOptions();
+ $options = $this->getCursorOptions();
$options['isNew'] = false;
$response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);
break;
@@ -309,4 +309,4 @@ private function getCursorOptions()
{
return $this->_cursorOptions;
}
-}
\ No newline at end of file
+}
diff --git a/lib/triagens/ArangoDb/CollectionHandler.php b/lib/triagens/ArangoDb/CollectionHandler.php
index 5be715ce..cd8adc9f 100644
--- a/lib/triagens/ArangoDb/CollectionHandler.php
+++ b/lib/triagens/ArangoDb/CollectionHandler.php
@@ -384,7 +384,7 @@ public function create($collection, $options = array())
* @param string $type - index type: hash, skiplist or geo
* @param array $attributes - an array of attributes that can be defined like array('a') or array('a', 'b.c')
* @param bool $unique - true/false to create a unique index
- * @param array $indexOptions - an associative array of options for the index like array('geoJson' => true)
+ * @param array $indexOptions - an associative array of options for the index like array('geoJson' => true)
*
* @return mixed - id of collection created
*/
@@ -397,9 +397,9 @@ public function index($collectionId, $type = "", $attributes = array(), $unique
self::OPTION_FIELDS => $attributes,
self::OPTION_UNIQUE => $unique
);
-
+
$bodyParams = array_merge($bodyParams, $indexOptions);
-
+
$url = UrlHelper::appendParamsUrl(Urls::URL_INDEX, $urlParams);
$response = $this->getConnection()->post($url, $this->json_encode_wrapper($bodyParams));
diff --git a/lib/triagens/ArangoDb/Connection.php b/lib/triagens/ArangoDb/Connection.php
index 342ff5cc..86b64946 100644
--- a/lib/triagens/ArangoDb/Connection.php
+++ b/lib/triagens/ArangoDb/Connection.php
@@ -367,7 +367,7 @@ private function executeRequest($method, $url, $data)
// call tracer func
$traceFunc('receive', $result);
}
-
+
if ($status['timed_out']) {
throw new ClientException('Got a timeout when waiting on the server\'s response');
}
diff --git a/lib/triagens/ArangoDb/Document.php b/lib/triagens/ArangoDb/Document.php
index 697e7777..720610af 100644
--- a/lib/triagens/ArangoDb/Document.php
+++ b/lib/triagens/ArangoDb/Document.php
@@ -51,12 +51,12 @@ class Document
* @var bool
*/
protected $_changed;
-
- /**
- * Flag to indicate whether document is a new document (never been saved to the server)
- *
- * @var bool
- */
+
+ /**
+ * Flag to indicate whether document is a new document (never been saved to the server)
+ *
+ * @var bool
+ */
protected $_isNew = true;
/**
@@ -80,10 +80,10 @@ class Document
* Revision id index
*/
const ENTRY_REV = '_rev';
-
- /**
- * isNew id index
- */
+
+ /**
+ * isNew id index
+ */
const ENTRY_ISNEW = '_isNew';
/**
@@ -123,10 +123,10 @@ public function __construct(array $options = array())
if (array_key_exists('_hiddenAttributes', $options)) {
$this->setHiddenAttributes($options['_hiddenAttributes']);
}
-
+
if (array_key_exists('_isNew', $options)) {
$this->setIsNew($options['_isNew']);
- }
+ }
}
/**
@@ -277,11 +277,11 @@ public function set($key, $value)
return;
}
-
- if ($key === self::ENTRY_ISNEW) {
- $this->setIsNew($value);
-
- return;
+
+ if ($key === self::ENTRY_ISNEW) {
+ $this->setIsNew($value);
+
+ return;
}
if (!$this->_changed) {
@@ -452,28 +452,28 @@ public function getChanged()
{
return $this->_changed;
}
-
- /**
- * Set the isNew flag
- *
- * @param bool $isNew - flags if new or existing doc
- *
- * @return void
- */
- public function setIsNew($isNew)
- {
- $this->_isNew = (bool)$isNew;
- }
-
- /**
- * Get the isNew flag
- *
- * @return bool $isNew - flags if new or existing doc
- */
- public function getIsNew()
- {
- return $this->_isNew;
- }
+
+ /**
+ * Set the isNew flag
+ *
+ * @param bool $isNew - flags if new or existing doc
+ *
+ * @return void
+ */
+ public function setIsNew($isNew)
+ {
+ $this->_isNew = (bool)$isNew;
+ }
+
+ /**
+ * Get the isNew flag
+ *
+ * @return bool $isNew - flags if new or existing doc
+ */
+ public function getIsNew()
+ {
+ return $this->_isNew;
+ }
/**
* Set the internal document id
diff --git a/lib/triagens/ArangoDb/DocumentHandler.php b/lib/triagens/ArangoDb/DocumentHandler.php
index 3e8e24e4..2c054865 100644
--- a/lib/triagens/ArangoDb/DocumentHandler.php
+++ b/lib/triagens/ArangoDb/DocumentHandler.php
@@ -182,48 +182,48 @@ public function add($collectionId, Document $document, $options = array())
{
return $this->save($collectionId, $document, $options);
}
-
- /**
- * Store a document to a collection
- *
+
+ /**
+ * Store a document to a collection
+ *
* This is an alias/shortcut to save() and replace(). Instead of having to determine which of the 3 functions to use,
- * simply pass the document to store() and it will figure out which one to call.
- *
- * This will throw if the document cannot be saved or replaced.
- *
- * @throws Exception
- *
- * @param mixed $collectionId - collection id as string or number
- * @param mixed $document - the document to be added, can be passed as a document or an array
- * @param bool|array $options - optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
- * Options are :
- *
'create' - create the collection if it does not yet exist.
- * 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
- *
- *
- * @return mixed - id of document created
- * @since 1.0
+ * simply pass the document to store() and it will figure out which one to call.
+ *
+ * This will throw if the document cannot be saved or replaced.
+ *
+ * @throws Exception
+ *
+ * @param mixed $collectionId - collection id as string or number
+ * @param mixed $document - the document to be added, can be passed as a document or an array
+ * @param bool|array $options - optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
+ * Options are :
+ *
'create' - create the collection if it does not yet exist.
+ * 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
+ *
+ *
+ * @return mixed - id of document created
+ * @since 1.0
*/
- public function store(Document $document, $collectionId = null, $options = array()){
-
- if($document->getIsNew()){
-
- if($collectionId == null){
- throw new ClientException('A collection id is required to store a new document.');
- }
-
- $result = $this->save($collectionId, $document, $options);
- $document->setIsNew(false);
-
- return $result;
- }else{
-
- if($collectionId){
- throw new ClientException('An existing document cannot be stored into a new collection');
- }
-
- return $this->replace($document, $options);
- }
+ public function store(Document $document, $collectionId = null, $options = array())
+ {
+ if($document->getIsNew()){
+
+ if($collectionId == null){
+ throw new ClientException('A collection id is required to store a new document.');
+ }
+
+ $result = $this->save($collectionId, $document, $options);
+ $document->setIsNew(false);
+
+ return $result;
+ }else{
+
+ if($collectionId){
+ throw new ClientException('An existing document cannot be stored into a new collection');
+ }
+
+ return $this->replace($document, $options);
+ }
}
@@ -288,9 +288,9 @@ public function save($collectionId, $document, $options = array())
if ($id != $document->getId()) {
throw new ClientException('Got an invalid response from the server');
}
-
+
$document->setIsNew(false);
-
+
return $document->getId();
}
diff --git a/lib/triagens/ArangoDb/EdgeHandler.php b/lib/triagens/ArangoDb/EdgeHandler.php
index 82c1a439..62f6650e 100644
--- a/lib/triagens/ArangoDb/EdgeHandler.php
+++ b/lib/triagens/ArangoDb/EdgeHandler.php
@@ -220,4 +220,4 @@ public function outEdges($collectionId, $vertexHandle)
{
return $this->edges($collectionId, $vertexHandle, 'out');
}
-}
\ No newline at end of file
+}
diff --git a/lib/triagens/ArangoDb/Graph.php b/lib/triagens/ArangoDb/Graph.php
index 20f72cc0..14889b3b 100644
--- a/lib/triagens/ArangoDb/Graph.php
+++ b/lib/triagens/ArangoDb/Graph.php
@@ -22,48 +22,48 @@
class Graph extends
Document
{
- /**
- * The collection used for vertices
- *
- * @var string - name of the vertices collection
- */
- protected $_verticesCollection = null;
-
- /**
- * The collection used for edges
- *
- * @var string - name of the edges collection
- */
- protected $_edgesCollection = null;
-
- /**
- * Graph vertices
- */
- const ENTRY_VERTICES = 'vertices';
-
- /**
- * Graph edges
- */
- const ENTRY_EDGES = 'edges';
-
- /**
- * Constructs an empty graph
- *
- * @param array $options - optional, initial $options for document
- *
- * @return void
- */
- public function __construct($name = null, array $options = array())
- {
-
- // prevent backwards compatibility break where the first parameter is the $options array
- if(!is_array($name) && $name != null){
- $this->set('_key', $name);
- }
-
- // pass the $options to the parent constructor to do the actual work
- parent::__construct($options);
- }
+ /**
+ * The collection used for vertices
+ *
+ * @var string - name of the vertices collection
+ */
+ protected $_verticesCollection = null;
+
+ /**
+ * The collection used for edges
+ *
+ * @var string - name of the edges collection
+ */
+ protected $_edgesCollection = null;
+
+ /**
+ * Graph vertices
+ */
+ const ENTRY_VERTICES = 'vertices';
+
+ /**
+ * Graph edges
+ */
+ const ENTRY_EDGES = 'edges';
+
+ /**
+ * Constructs an empty graph
+ *
+ * @param array $options - optional, initial $options for document
+ *
+ * @return void
+ */
+ public function __construct($name = null, array $options = array())
+ {
+
+ // prevent backwards compatibility break where the first parameter is the $options array
+ if(!is_array($name) && $name != null){
+ $this->set('_key', $name);
+ }
+
+ // pass the $options to the parent constructor to do the actual work
+ parent::__construct($options);
+ }
/**
* Set the vertices-collection of the graph
@@ -116,7 +116,7 @@ public function getEdgesCollection()
{
return $this->_edgesCollection;
}
-
+
/**
* Set a graph attribute
*
@@ -133,30 +133,30 @@ public function getEdgesCollection()
*/
public function set($key, $value)
{
-
- if(in_array($key, array(self::ENTRY_VERTICES, self::ENTRY_EDGES))){
-
- if (!is_string($key)) {
- throw new ClientException('Invalid document attribute key');
- }
-
- // validate the value passed
- ValueValidator::validate($value);
-
- if ($key === self::ENTRY_VERTICES) {
- $this->setVerticesCollection($value);
-
- return;
- }
-
- if ($key === self::ENTRY_EDGES) {
- $this->setEdgesCollection($value);
-
- return;
- }
-
- }else{
- parent::set($key, $value);
- }
+
+ if(in_array($key, array(self::ENTRY_VERTICES, self::ENTRY_EDGES))){
+
+ if (!is_string($key)) {
+ throw new ClientException('Invalid document attribute key');
+ }
+
+ // validate the value passed
+ ValueValidator::validate($value);
+
+ if ($key === self::ENTRY_VERTICES) {
+ $this->setVerticesCollection($value);
+
+ return;
+ }
+
+ if ($key === self::ENTRY_EDGES) {
+ $this->setEdgesCollection($value);
+
+ return;
+ }
+
+ }else{
+ parent::set($key, $value);
+ }
}
}
diff --git a/lib/triagens/ArangoDb/GraphHandler.php b/lib/triagens/ArangoDb/GraphHandler.php
index e6aba1fc..f64088cc 100644
--- a/lib/triagens/ArangoDb/GraphHandler.php
+++ b/lib/triagens/ArangoDb/GraphHandler.php
@@ -90,35 +90,35 @@ public function createGraph(Graph $graph)
return $graph->getAll();
}
- /**
- * Get a graph
- *
- * This will get a graph.
- *
- * This will throw if the graph cannot be retrieved.
- *
- * @throws Exception
- *
- * @param String - $graph - The name of the graph
- *
- * @return Graph - A graph object representing the graph
- * @since 1.2
- *
- * @example "ArangoDb/examples/graph.php" How to use this function
- * @example "ArangoDb/examples/graph.php" How to use this function
- */
- public function getGraph($graph, array $options = array())
- {
- $url = UrlHelper::buildUrl(Urls::URL_GRAPH, $graph);
- $response = $this->getConnection()->get($url);
- $data = $response->getJson();
-
- if($data['error']){
- return false;
- }
-
- $options['_isNew'] = false;
- return Graph::createFromArray($data['graph'], $options);
+ /**
+ * Get a graph
+ *
+ * This will get a graph.
+ *
+ * This will throw if the graph cannot be retrieved.
+ *
+ * @throws Exception
+ *
+ * @param String - $graph - The name of the graph
+ *
+ * @return Graph - A graph object representing the graph
+ * @since 1.2
+ *
+ * @example "ArangoDb/examples/graph.php" How to use this function
+ * @example "ArangoDb/examples/graph.php" How to use this function
+ */
+ public function getGraph($graph, array $options = array())
+ {
+ $url = UrlHelper::buildUrl(Urls::URL_GRAPH, $graph);
+ $response = $this->getConnection()->get($url);
+ $data = $response->getJson();
+
+ if($data['error']){
+ return false;
+ }
+
+ $options['_isNew'] = false;
+ return Graph::createFromArray($data['graph'], $options);
}
@@ -779,4 +779,4 @@ public function getConnectedEdges($graphName, $vertexId, $options = array())
return new Cursor($this->getConnection(), $response->getJson(), $options);
}
-}
\ No newline at end of file
+}
diff --git a/lib/triagens/ArangoDb/HttpHelper.php b/lib/triagens/ArangoDb/HttpHelper.php
index b00d6770..b14c6510 100644
--- a/lib/triagens/ArangoDb/HttpHelper.php
+++ b/lib/triagens/ArangoDb/HttpHelper.php
@@ -167,7 +167,7 @@ public static function transfer($socket, $request)
if (! is_resource($socket)) {
throw new ClientException('Invalid socket used');
}
-
+
assert(is_string($request));
@fwrite($socket, $request);
diff --git a/lib/triagens/ArangoDb/Statement.php b/lib/triagens/ArangoDb/Statement.php
index 086ae050..a1d7527b 100644
--- a/lib/triagens/ArangoDb/Statement.php
+++ b/lib/triagens/ArangoDb/Statement.php
@@ -20,7 +20,7 @@
* There is an important distinction between two different types of statements:
* - statements that produce a list of documents as their result AND
* - statements that do not produce documents
- *
+ *
* For example, a statement such as "FOR e IN example RETURN e" will produce
* a list of documents as its result. The result can be treated as a list of
* documents, and the document can be updated and sent back to the server by
@@ -75,7 +75,7 @@ class Statement
* @var string
*/
private $_query = null;
-
+
/**
* "flat" flag (if set, the query results will be treated as a simple array, not documents)
*
@@ -115,13 +115,13 @@ class Statement
*
* The $data property can be used to specify the query text and further
* options for the query.
- *
- * An important consideration when creating a statement is whether the
+ *
+ * An important consideration when creating a statement is whether the
* statement will produce a list of documents as its result or any other
- * non-document value. When a statement is created, by default it is
+ * non-document value. When a statement is created, by default it is
* assumed that the statement will produce documents. If this is not the
* case, executing a statement that returns non-documents will fail.
- *
+ *
* To explicitly mark the statement as returning non-documents, the '_flat'
* option should be specified in $data.
*
@@ -154,7 +154,7 @@ public function __construct(Connection $connection, array $data)
if (isset($data[Cursor::ENTRY_SANITIZE])) {
$this->_sanitize = (bool) $data[Cursor::ENTRY_SANITIZE];
}
-
+
if (isset($data[Cursor::ENTRY_FLAT])) {
$this->_flat = (bool) $data[Cursor::ENTRY_FLAT];
}
diff --git a/lib/triagens/ArangoDb/UrlHelper.php b/lib/triagens/ArangoDb/UrlHelper.php
index 3df6e56c..e0bab2ea 100644
--- a/lib/triagens/ArangoDb/UrlHelper.php
+++ b/lib/triagens/ArangoDb/UrlHelper.php
@@ -15,7 +15,7 @@
*
* @package ArangoDbPhpClient
*/
-abstract class URLHelper
+abstract class UrlHelper
{
/**
* Get the document id from a location header
diff --git a/lib/triagens/ArangoDb/Urls.php b/lib/triagens/ArangoDb/Urls.php
index 00426238..3791cbed 100644
--- a/lib/triagens/ArangoDb/Urls.php
+++ b/lib/triagens/ArangoDb/Urls.php
@@ -15,7 +15,7 @@
*
* @package ArangoDbPhpClient
*/
-abstract class URLs
+abstract class Urls
{
/**
* URL base part for all document-related REST calls
diff --git a/lib/triagens/ArangoDb/UserHandler.php b/lib/triagens/ArangoDb/UserHandler.php
index d90ab127..91b6b89c 100644
--- a/lib/triagens/ArangoDb/UserHandler.php
+++ b/lib/triagens/ArangoDb/UserHandler.php
@@ -169,4 +169,4 @@ public function removeUser($username)
return true;
}
-}
\ No newline at end of file
+}
diff --git a/lib/triagens/ArangoDb/VertexHandler.php b/lib/triagens/ArangoDb/VertexHandler.php
index 25db9427..93c11a22 100644
--- a/lib/triagens/ArangoDb/VertexHandler.php
+++ b/lib/triagens/ArangoDb/VertexHandler.php
@@ -24,4 +24,4 @@ class VertexHandler extends
DocumentHandler
{
-}
\ No newline at end of file
+}
diff --git a/tests/BatchTest.php b/tests/BatchTest.php
index 3d019a86..0b6c157d 100644
--- a/tests/BatchTest.php
+++ b/tests/BatchTest.php
@@ -160,7 +160,7 @@ public function testCreateMixedBatchWithPartIds()
$batch = new Batch($this->connection);
$this->assertInstanceOf('\triagens\ArangoDb\Batch', $batch);
- // Create collection
+ // Create collection
$connection = $this->connection;
$collection = new Collection();
$collectionHandler = new CollectionHandler($connection);
diff --git a/tests/CollectionExtendedTest.php b/tests/CollectionExtendedTest.php
index 24c6dec0..b9e5a113 100644
--- a/tests/CollectionExtendedTest.php
+++ b/tests/CollectionExtendedTest.php
@@ -196,7 +196,7 @@ public function testCreateRenameAndDeleteCollectionWithWrongEncoding()
$resultingCollection = $collectionHandler->get($name);
- // inject wrong encoding
+ // inject wrong encoding
$isoValue = iconv("UTF-8", "ISO-8859-1//TRANSLIT", "ArangoDB_PHP_TestSuite_TestCollection_01_renamedü");
$response = $collectionHandler->rename($resultingCollection, $isoValue);
@@ -1142,7 +1142,7 @@ public function testGetAll()
public function testCreateSkipListIndexedCollectionAddDocumentsAndQueryRange()
{
- // set up collections, indexes and test-documents
+ // set up collections, indexes and test-documents
$collectionHandler = $this->collectionHandler;
$collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_01'));
@@ -1276,7 +1276,7 @@ public function testCreateSkipListIndexedCollectionAddDocumentsAndQueryRange()
*/
public function testCreateGeoIndexedCollectionAddDocumentsAndQueryNear()
{
- // set up collections, indexes and test-documents
+ // set up collections, indexes and test-documents
$collectionHandler = $this->collectionHandler;
$collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_01'));
@@ -1382,7 +1382,7 @@ public function testCreateGeoIndexedCollectionAddDocumentsAndQueryNear()
*/
public function testCreateGeoIndexedCollectionAddDocumentsAndQueryWithin()
{
- // set up collections, indexes and test-documents
+ // set up collections, indexes and test-documents
$collectionHandler = $this->collectionHandler;
$collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_01'));
@@ -1515,41 +1515,41 @@ public function testCreateFulltextIndexedCollectionAddDocumentsAndQuery()
$response = $collectionHandler->delete($collection);
$this->assertTrue($response, 'Delete should return true!');
}
-
+
public function testCreateFulltextIndexedCollectionWithOptions()
{
- // set up collections and index
- $collectionHandler = $this->collectionHandler;
-
- $collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_01'));
- $response = $collectionHandler->add($collection);
-
- $indexRes = $collectionHandler->index($collection->getName(), 'fulltext', array('name'), false, array('minLength' => 10));
-
- $this->assertArrayHasKey(
- 'isNewlyCreated',
- $indexRes,
- "index creation result should have the isNewlyCreated key !"
- );
-
- $this->assertArrayHasKey('minLength', $indexRes, 'index creation result should have a minLength key!');
-
- $this->assertEquals(10, $indexRes['minLength'], 'index created does not have the same minLength as the one sent!');
-
- // Check if the index is returned in the indexes of the collection
- $indexes = $collectionHandler->getIndexes($collection->getName());
- $this->assertTrue($indexes['indexes'][1]['fields'][0] === 'name', 'The index should be on field "name"!');
-
- // Drop the index
- $collectionHandler->dropIndex($indexes['indexes'][1]['id']);
- $indexes = $collectionHandler->getIndexes($collection->getName());
-
- // Check if the index is not in the indexes of the collection anymore
- $this->assertArrayNotHasKey(1, $indexes['indexes'], 'There should not be an index on field "name"!');
-
- // Clean up...
- $response = $collectionHandler->delete($collection);
- $this->assertTrue($response, 'Delete should return true!');
+ // set up collections and index
+ $collectionHandler = $this->collectionHandler;
+
+ $collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_01'));
+ $response = $collectionHandler->add($collection);
+
+ $indexRes = $collectionHandler->index($collection->getName(), 'fulltext', array('name'), false, array('minLength' => 10));
+
+ $this->assertArrayHasKey(
+ 'isNewlyCreated',
+ $indexRes,
+ "index creation result should have the isNewlyCreated key !"
+ );
+
+ $this->assertArrayHasKey('minLength', $indexRes, 'index creation result should have a minLength key!');
+
+ $this->assertEquals(10, $indexRes['minLength'], 'index created does not have the same minLength as the one sent!');
+
+ // Check if the index is returned in the indexes of the collection
+ $indexes = $collectionHandler->getIndexes($collection->getName());
+ $this->assertTrue($indexes['indexes'][1]['fields'][0] === 'name', 'The index should be on field "name"!');
+
+ // Drop the index
+ $collectionHandler->dropIndex($indexes['indexes'][1]['id']);
+ $indexes = $collectionHandler->getIndexes($collection->getName());
+
+ // Check if the index is not in the indexes of the collection anymore
+ $this->assertArrayNotHasKey(1, $indexes['indexes'], 'There should not be an index on field "name"!');
+
+ // Clean up...
+ $response = $collectionHandler->delete($collection);
+ $this->assertTrue($response, 'Delete should return true!');
}
diff --git a/tests/DocumentExtendedTest.php b/tests/DocumentExtendedTest.php
index dbb21831..f91824d7 100644
--- a/tests/DocumentExtendedTest.php
+++ b/tests/DocumentExtendedTest.php
@@ -279,7 +279,7 @@ public function testUpdateDocumentWithWrongEncoding()
$patchDocument->set('_id', $document->getHandle());
$patchDocument->set('_rev', $document->getRevision());
- // inject wrong encoding
+ // inject wrong encoding
$isoValue = iconv("UTF-8", "ISO-8859-1//TRANSLIT", "someWrongEncodedValueü");
$patchDocument->set('someOtherAttribute', $isoValue);
@@ -396,7 +396,7 @@ public function testReplaceDocumentWithWrongEncoding()
$this->assertTrue(is_numeric($documentId), 'Did not return an id!');
- // inject wrong encoding
+ // inject wrong encoding
$isoKey = iconv("UTF-8", "ISO-8859-1//TRANSLIT", "someWrongEncododedAttribute");
$isoValue = iconv("UTF-8", "ISO-8859-1//TRANSLIT", "someWrongEncodedValueü");
@@ -818,47 +818,47 @@ public function testGetReplaceUpdateAndRemoveOnNonExistantObjects()
*/
public function testStoreNewDocumentThenReplace()
{
- //Setup
- $document = new Document();
- $document->set('data', 'this is some test data');
-
- //Check that the document is new
- $this->assertTrue($document->getIsNew(), 'Document is not marked as new when it is a new document.');
-
- $documentHandler = $this->documentHandler;
-
- //Store the document
- $id = $documentHandler->store($document, $this->collection->getId());
-
- $rev = $document->getRevision();
-
- $this->assertTrue($id == $document->getId(), 'Returned ID does not match the one in the document');
- $this->assertTrue($document->get('data') == 'this is some test data', 'Data has been modified for some reason.');
-
- //Check that the document is not new
- $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
-
- //Update the document and save again
- $document->set('data', 'this is some different data');
- $document->set('favorite_sport', 'hockey');
- $documentHandler->store($document);
-
- //Check that the id remains the same
- $this->assertTrue($document->getId() == $id, 'ID of updated document does not match the initial ID.');
-
- //Retrieve a copy of the document from the server
- $document = $documentHandler->get($this->collection->getId(), $id);
-
- //Assert that it is not new
- $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
-
- //Assert the id is the same
- $this->assertTrue($document->getId() == $id, 'ID of retrieved document does not match expected ID');
-
- //Assert new data has been saved
- $this->assertTrue($document->get('favorite_sport') == 'hockey', 'Retrieved data does not match.');
-
- $this->assertTrue($document->getRevision() != $rev, 'Revision matches when it is not suppose to.');
+ //Setup
+ $document = new Document();
+ $document->set('data', 'this is some test data');
+
+ //Check that the document is new
+ $this->assertTrue($document->getIsNew(), 'Document is not marked as new when it is a new document.');
+
+ $documentHandler = $this->documentHandler;
+
+ //Store the document
+ $id = $documentHandler->store($document, $this->collection->getId());
+
+ $rev = $document->getRevision();
+
+ $this->assertTrue($id == $document->getId(), 'Returned ID does not match the one in the document');
+ $this->assertTrue($document->get('data') == 'this is some test data', 'Data has been modified for some reason.');
+
+ //Check that the document is not new
+ $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
+
+ //Update the document and save again
+ $document->set('data', 'this is some different data');
+ $document->set('favorite_sport', 'hockey');
+ $documentHandler->store($document);
+
+ //Check that the id remains the same
+ $this->assertTrue($document->getId() == $id, 'ID of updated document does not match the initial ID.');
+
+ //Retrieve a copy of the document from the server
+ $document = $documentHandler->get($this->collection->getId(), $id);
+
+ //Assert that it is not new
+ $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
+
+ //Assert the id is the same
+ $this->assertTrue($document->getId() == $id, 'ID of retrieved document does not match expected ID');
+
+ //Assert new data has been saved
+ $this->assertTrue($document->get('favorite_sport') == 'hockey', 'Retrieved data does not match.');
+
+ $this->assertTrue($document->getRevision() != $rev, 'Revision matches when it is not suppose to.');
}
public function tearDown()
diff --git a/tests/GraphBasicTest.php b/tests/GraphBasicTest.php
index 13f95c10..484ad346 100644
--- a/tests/GraphBasicTest.php
+++ b/tests/GraphBasicTest.php
@@ -44,7 +44,7 @@ public function testCreateAndDeleteGraph()
$result = $this->graphHandler->dropGraph('Graph1');
$this->assertTrue($result, 'Did not return true!');
}
-
+
/**
* Test if Edge and EdgeHandler instances can be initialized when we directly set the graph name in the constructor
*/
@@ -57,31 +57,31 @@ public function testCreateAndDeleteGraphByName()
$result = $this->graphHandler->createGraph($this->graph);
$this->assertTrue($result['_key'] == 'Graph2', 'Did not return Graph2!');
-
+
$properties = $this->graphHandler->properties('Graph2');
$this->assertTrue($properties['_key'] == 'Graph2', 'Did not return Graph2!');
-
+
$result = $this->graphHandler->dropGraph('Graph2');
$this->assertTrue($result, 'Did not return true!');
}
-
- /**
- * Test if we can create a graph and then retrieve it from the server
- */
- public function testCreateRetrieveAndDeleteGraph()
- {
- $this->graph = new \triagens\ArangoDb\Graph('Graph3');
- $this->graph->setVerticesCollection('ArangoDBPHPTestSuiteTestCollection03');
- $this->graph->setEdgesCollection('ArangoDBPHPTestSuiteTestEdgeCollection03');
- $this->graphHandler = new \triagens\ArangoDb\GraphHandler($this->connection);
-
- $this->graphHandler->createGraph($this->graph);
-
- $graph = $this->graphHandler->getGraph('Graph3');
- $this->assertTrue($graph->getKey() == 'Graph3', 'Did not return Graph3!');
-
- $result = $this->graphHandler->dropGraph('Graph3');
- $this->assertTrue($result, 'Did not return true!');
+
+ /**
+ * Test if we can create a graph and then retrieve it from the server
+ */
+ public function testCreateRetrieveAndDeleteGraph()
+ {
+ $this->graph = new \triagens\ArangoDb\Graph('Graph3');
+ $this->graph->setVerticesCollection('ArangoDBPHPTestSuiteTestCollection03');
+ $this->graph->setEdgesCollection('ArangoDBPHPTestSuiteTestEdgeCollection03');
+ $this->graphHandler = new \triagens\ArangoDb\GraphHandler($this->connection);
+
+ $this->graphHandler->createGraph($this->graph);
+
+ $graph = $this->graphHandler->getGraph('Graph3');
+ $this->assertTrue($graph->getKey() == 'Graph3', 'Did not return Graph3!');
+
+ $result = $this->graphHandler->dropGraph('Graph3');
+ $this->assertTrue($result, 'Did not return true!');
}
@@ -91,4 +91,4 @@ public function tearDown()
unset($this->graphHandler);
unset($this->connection);
}
-}
\ No newline at end of file
+}
diff --git a/tests/GraphExtendedTest.php b/tests/GraphExtendedTest.php
index 679c2a36..2cd4c0af 100644
--- a/tests/GraphExtendedTest.php
+++ b/tests/GraphExtendedTest.php
@@ -1043,4 +1043,4 @@ public function tearDown()
unset($this->graphHandler);
unset($this->connection);
}
-}
\ No newline at end of file
+}
diff --git a/tests/UserBasicTest.php b/tests/UserBasicTest.php
index d22772af..92296d19 100644
--- a/tests/UserBasicTest.php
+++ b/tests/UserBasicTest.php
@@ -109,7 +109,8 @@ public function testAddReplaceUpdateGetAndDeleteUserWithNonNullValues()
// test functions on non-existant user
- public function testFunctionsOnNonExistantUser(){
+ public function testFunctionsOnNonExistantUser()
+ {
$connection = $this->connection;
$this->userHandler = new \triagens\ArangoDb\UserHandler($this->connection);
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 9e2f404a..352d812f 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -15,8 +15,8 @@
/* set up a trace function that will be called for each communication with the server */
-function getConnectionOptions(){
-
+function getConnectionOptions()
+{
$traceFunc = function($type, $data) {
print "TRACE FOR ". $type . PHP_EOL;
};
@@ -39,7 +39,7 @@ function getConnectionOptions(){
}
-function getConnection(){
+function getConnection()
+{
return new Connection(getConnectionOptions());
}
-