Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Requests/Mail/MailSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function create(string $id, mixed $object = null): MailParameters
* @param MailParameters|null $object Email parameters object
* @return MailParameters The email parameters for method chaining
*/
public function update(string $id, mixed $object = null): MailParameters
public function update(string $id, mixed $object = null): MailParameters|stdClass
{
return parent::update($id, $object);
}
Expand Down
16 changes: 12 additions & 4 deletions lib/Requests/RequestSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,32 @@ public function create(string $id, mixed $object = null): RequestParametersInter
*
* @return TParameters The parameters object for method chaining
*/
protected function update(string $id, RequestParametersInterface|null $object = null): RequestParametersInterface
protected function update(string $id, RequestParametersInterface|array|null $object = null): RequestParametersInterface|stdClass
{
// get the class to use (override or default)
$class = RequestClasses::getParameter($this->_class . '.object') ?? $this->_parametersClass;

// validate object type if provided
if ($object !== null && !($object instanceof $class)) {
if ($object !== null && !($object instanceof $class) && !is_array($object)) {
throw new InvalidParameterTypeException($class, $object, 'object');
}

// evaluate if update parameter exist and create if needed
if (!isset($this->_command['update'][$id]) && $object === null) {
$this->_command['update'][$id] = new \stdClass();
} elseif ($object !== null) {
$object->bind($this->_command['update'][$id]);
if ($object instanceof $class) {
$object->bind($this->_command['update'][$id]);
} elseif (is_array($object)) {
$this->_command['update'][$id] = (object)$object;
}
}
// return instance of the specific parameters class
$instance = new $class($this->_command['update'][$id]);
if ($object instanceof $class) {
$instance = new $class($this->_command['update'][$id]);
} else {
$instance = $this->_command['update'][$id];
}

return $instance;
}
Expand Down
Loading