aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Schemas/ResourcePropertySchema.php
blob: d9caf30ecc9082fa7895c01c8605b44f1177fda8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace JsonApi\Schemas;

use Neomerx\JsonApi\Contracts\Schema\ContextInterface;
use ResourceProperty;

final class ResourcePropertySchema extends SchemaProvider
{
    /**
     * @param ResourceProperty $resource
     */
    public function getId($resource): ?string
    {
        return $resource->id;
    }

    /**
     * @param ResourceProperty $resource
     */
    public function getAttributes($resource, ContextInterface $context): iterable
    {
        return [
            'state' => $resource->state,

            'mkdate' => date('c', $resource->mkdate),
            'chdate' => date('c', $resource->chdate),
        ];
    }

    /**
     * @param ResourceProperty $resource
     */
    public function getRelationships($resource, ContextInterface $context): iterable
    {
        return [];
    }
}