From f3301d9427d24c080ec92106cd630b0646682d0c Mon Sep 17 00:00:00 2001 From: Juvenn Woo Date: Mon, 26 Oct 2015 10:56:21 +0800 Subject: [PATCH] Value operation methods return $this for chain operations --- src/LeanCloud/LeanObject.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/LeanCloud/LeanObject.php b/src/LeanCloud/LeanObject.php index 0d19693..edc2293 100644 --- a/src/LeanCloud/LeanObject.php +++ b/src/LeanCloud/LeanObject.php @@ -176,7 +176,7 @@ public function getUpdatedAt() { * Set field value by key. * @param string $key field key * @param mixed $val field value - * @return void + * @return $this * @throws RuntimeException */ public function set($key, $val) { @@ -187,16 +187,18 @@ public function set($key, $val) { $val = new SetOperation($key, $val); } $this->_applyOperation($val); + return $this; } /** * Delete field by key. * * @param string $key Field key - * @return void + * @return $this */ public function delete($key) { $this->_applyOperation(new DeleteOperation($key)); + return $this; } /** @@ -223,9 +225,11 @@ public function get($key) { * * @param string $key field key * @param number $amount amount to increment + * @return $this */ public function increment($key, $amount = 1) { $this->_applyOperation(new IncrementOperation($key, $amount)); + return $this; } /** @@ -267,11 +271,12 @@ private function _applyOperation($operation) { * * @param string $key Field key * @param miexed $val Object to add - * @return void + * @return $this * @throws RuntimeException When adding to non-array field */ public function add($key, $val) { $this->_applyOperation(new ArrayOperation($key, array($val), "Add")); + return $this; } /** @@ -279,13 +284,14 @@ public function add($key, $val) { * * @param string $key Field key * @param mixed $val Object to add - * @return void + * @return $this * @throws RuntimeException When adding to non-array field */ public function addUnique($key, $val) { $this->_applyOperation(new ArrayOperation($key, array($val), "AddUnique")); + return $this; } /** @@ -293,11 +299,12 @@ public function addUnique($key, $val) { * * @param string $key Field key * @param mixed $val Object to remove - * @return void + * @return $this * @throws RuntimeException When removing from non-array field */ public function remove($key, $val) { $this->_applyOperation(new ArrayOperation($key, array($val), "Remove")); + return $this; } /**