Api4 - Use explicit adder functions rather than magicMethod
[civicrm-core.git] / Civi / Api4 / Generic / AbstractUpdateAction.php
index d0f81572de884ca7dcc56ea74da50e4d7a32e2fd..b3fe4d86352729be0c2e0eeaa373af6c9fdcf2e6 100644 (file)
@@ -25,7 +25,6 @@ namespace Civi\Api4\Generic;
  * Base class for all "Update" api actions
  *
  * @method $this setValues(array $values) Set all field values from an array of key => value pairs.
- * @method $this addValue($field, $value) Set field value.
  * @method array getValues() Get field values.
  * @method $this setReload(bool $reload) Specify whether complete objects will be returned after saving.
  * @method bool getReload()
@@ -53,12 +52,23 @@ abstract class AbstractUpdateAction extends AbstractBatchAction {
   protected $reload = FALSE;
 
   /**
-   * @param string $key
+   * @param string $fieldName
    *
    * @return mixed|null
    */
-  public function getValue($key) {
-    return isset($this->values[$key]) ? $this->values[$key] : NULL;
+  public function getValue(string $fieldName) {
+    return isset($this->values[$fieldName]) ? $this->values[$fieldName] : NULL;
+  }
+
+  /**
+   * Add an item to the values array
+   * @param string $fieldName
+   * @param mixed $value
+   * @return $this
+   */
+  public function addValue(string $fieldName, $value) {
+    $this->values[$fieldName] = $value;
+    return $this;
   }
 
 }