Skip to content

Commit c42e98f

Browse files
committed
cosmetic changes
1 parent e5f686c commit c42e98f

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Release notes for the ArangoDB-PHP driver 3.5.x
22
===============================================
33

4+
Made `DocumentHandler::save()` an alias for `DocumentHandler::insert()`, to more closely
5+
match the function names used in arangosh/arangod.
6+
47
Added support for streaming transactions (i.e. transactions that can be composed of multiple
58
operations on the client side piece-by-piece without specifying the full transaction operations
69
in advance).

lib/ArangoDBClient/DocumentHandler.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public function store(Document $document, $collection = null, array $options = [
317317

318318

319319
/**
320-
* save a document to a collection
320+
* insert a document into a collection
321321
*
322322
* This will add the document to the collection and return the document's id
323323
*
@@ -339,7 +339,7 @@ public function store(Document $document, $collection = null, array $options = [
339339
* @return mixed - id of document created
340340
* @since 1.0
341341
*/
342-
public function save($collection, $document, array $options = [])
342+
public function insert($collection, $document, array $options = [])
343343
{
344344
$headers = [];
345345
$this->addTransactionHeader($headers, $collection);
@@ -409,11 +409,11 @@ public function save($collection, $document, array $options = [])
409409
/**
410410
* Insert a document into a collection
411411
*
412-
* This is an alias for save().
412+
* This is an alias for insert().
413413
*/
414-
public function insert($collection, $document, array $options = [])
414+
public function save($collection, $document, array $options = [])
415415
{
416-
return $this->save($collection, $document, $options);
416+
return $this->insert($collection, $document, $options);
417417
}
418418

419419
/**
@@ -548,30 +548,28 @@ protected function patch($url, $collection, $documentId, Document $document, arr
548548
/**
549549
* Replace an existing document in a collection, identified by the document itself
550550
*
551-
* This will update the document on the server
551+
* This will replace the document on the server
552552
*
553-
* This will throw if the document cannot be updated
553+
* This will throw if the document cannot be replaced
554554
*
555555
* If policy is set to error (locally or globally through the ConnectionOptions)
556556
* and the passed document has a _rev value set, the database will check
557557
* that the revision of the to-be-replaced document is the same as the one given.
558558
*
559559
* @throws Exception
560560
*
561-
* @param Document $document - document to be updated
561+
* @param Document $document - document to be replaced
562562
* @param array $options - optional, array of options
563563
* <p>Options are :
564-
* <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
564+
* <li>'policy' - replace policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
565565
* <li>'waitForSync' - 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>
566566
* </p>
567567
*
568568
* @return bool - always true, will throw if there is an error
569569
*/
570570
public function replace(Document $document, array $options = [])
571571
{
572-
$documentId = $this->getDocumentId($document);
573-
574-
return $this->replaceById($document, $documentId, $document, $options);
572+
return $this->replaceById($document, $this->getDocumentId($document), $document, $options);
575573
}
576574

577575

tests/DocumentBasicTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ public function testCreateAndDeleteDocumentWithoutCreatedCollectionAndOptionCrea
206206
$document = new Document();
207207
$documentHandler = new DocumentHandler($connection);
208208

209-
$options = $connection->getOptions();
210-
$connection->setOption(ConnectionOptions::OPTION_CREATE, true);
209+
$options = $connection->getOptions();
210+
$connection->setOption(ConnectionOptions::OPTION_CREATE, true);
211211

212212
try {
213213
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01' . '_' . static::$testsTimestamp);

0 commit comments

Comments
 (0)