for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Mikemirten\Component\JsonApi\Document\Behaviour;
/**
* Class ResourceBehaviour
*
* @see http://jsonapi.org/format/#document-resource-objects
* @see http://jsonapi.org/format/#document-resource-identifier-objects
* @package Mikemirten\Component\JsonApi\Document\Behaviour
*/
trait ResourceBehaviour
{
* ID of resource
* @var string
protected $id;
* Type of resource
protected $type;
* Get ID of resource
* @return string
public function getId(): string
return $this->id;
}
* Get type of resource
public function getType(): string
return $this->type;
* Cast resource to an array
* @return array
protected function resourceToArray(): array
return [
'id' => $this->getId(),
'type' => $this->getType()
];