setKey($key); } if (isset($value)) { $this->setValue($value); } } /** * Add a custom arg key on a CustomArg object * * @param string $key Custom arg key * * @throws \SendGrid\Mail\TypeException */ public function setKey($key) { Assert::string($key, 'key'); $this->key = $key; } /** * Retrieve a custom arg key on a CustomArg object * * @return string */ public function getKey() { return $this->key; } /** * Add a custom arg value on a CustomArg object * * @param string $value Custom arg value * * @throws \SendGrid\Mail\TypeException */ public function setValue($value) { Assert::string($value, 'value'); $this->value = $value; } /** * Retrieve a custom arg key on a CustomArg object * * @return string */ public function getValue() { return $this->value; } /** * Return an array representing a CustomArg object for the Twilio SendGrid API * * @return null|array */ public function jsonSerialize() { return array_filter( [ 'key' => $this->getKey(), 'value' => $this->getValue() ], function ($value) { return $value !== null; } ) ?: null; } }