mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 08:17:18 +08:00
git-subtree-dir: public/legacy git-subtree-split: 817a12dc0c30c189f56d5cb1f7dc37a9631bdbe3
29 lines
830 B
PHP
29 lines
830 B
PHP
<?php
|
|
namespace Api\V8\JsonApi\Response;
|
|
|
|
class AttributeResponse extends MetaResponse
|
|
{
|
|
/**
|
|
* @var array
|
|
*
|
|
* @see http://jsonapi.org/format/#document-resource-object-attributes
|
|
*/
|
|
private static $forbiddenKeys = ['relationships', 'links'];
|
|
|
|
/**
|
|
* @param array|\stdClass $properties
|
|
*
|
|
* @throws \InvalidArgumentException When attribute object includes forbidden keys.
|
|
*/
|
|
public function __construct($properties = [])
|
|
{
|
|
parent::__construct($properties);
|
|
|
|
$invalidKeys = array_intersect_key($properties, array_flip(self::$forbiddenKeys));
|
|
if ($invalidKeys) {
|
|
throw new \InvalidArgumentException(
|
|
'Attribute object must not contain these keys: ' . implode(', ', array_keys($invalidKeys))
|
|
);
|
|
}
|
|
}
|
|
}
|