SuiteCRM-Core/Api/V8/JsonApi/Response/MetaResponse.php
Dillon-Brown 8e4cc94994 Squashed 'public/legacy/' content from commit 817a12dc0
git-subtree-dir: public/legacy
git-subtree-split: 817a12dc0c30c189f56d5cb1f7dc37a9631bdbe3
2021-03-31 15:37:32 +01:00

55 lines
1.2 KiB
PHP

<?php
namespace Api\V8\JsonApi\Response;
class MetaResponse implements \JsonSerializable
{
/**
* @var array
*/
protected $properties = [];
/**
* Meta object can contain any properties.
*
* @param array|\stdClass $properties
*
* @throws \InvalidArgumentException When bean is not found with the given id.
*/
public function __construct($properties = [])
{
if (!is_array($properties) && !$properties instanceof \stdClass) {
throw new \InvalidArgumentException('The properties must be an array or sdtClass');
}
foreach ($properties as $property => $value) {
$this->$property = $value;
}
}
/**
* @param string $name
*
* @return mixed|null
*/
public function __get($name)
{
return isset($this->properties[$name]) ? $this->properties[$name] : null;
}
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
$this->properties[$name] = $value;
}
/**
* @inheritdoc
*/
public function jsonSerialize()
{
return $this->properties;
}
}