StandardExtension::buildSchema()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 27
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 21
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Description\Schema\Extension;
6
7
use Psi\Component\Description\Schema\ExtensionInterface;
8
use Psi\Component\Description\Schema\Builder;
9
use Psi\Component\Description\Descriptor\UriDescriptor;
10
use Psi\Component\Description\Descriptor\StringDescriptor;
11
use Psi\Component\Description\Descriptor\DateTimeDescriptor;
12
use Psi\Component\Description\Descriptor\ClassDescriptor;
13
14
/**
15
 * Standard descriptors.
16
 *
17
 * Provide a list of general, commonly required, descriptors.
18
 */
19
class StandardExtension implements ExtensionInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function buildSchema(Builder $builder)
25
    {
26
        $builder->add(
27
            'class',
28
            ClassDescriptor::class,
29
            'Resolved reflection class. Note that this should be the reflection of the *real* class '.
30
            '(as opposed to that of a proxy if applicable)'
31
        );
32
        $builder->add(
33
            'identifier',
34
            StringDescriptor::class,
35
            'Identifier for object (e.g. primary key / UUID)'
36
        );
37
        $builder->add('class.alias', StringDescriptor::class, 'Alias for the class');
38
39
        $builder->add('title', StringDescriptor::class, 'Title to use for the object instance');
40
        $builder->add('description', StringDescriptor::class, 'Description of the object');
41
        $builder->add('image', UriDescriptor::class, 'URL to image');
42
        $builder->add('created_at', DateTimeDescriptor::class, 'Date this object was created');
43
        $builder->add('updated_at', DateTimeDescriptor::class, 'Date this object was updated');
44
45
        $builder->add('uri.create', UriDescriptor::class, 'Uri to where the object can be created');
46
        $builder->add('uri.show', UriDescriptor::class, 'Uri to where the object can be shown');
47
        $builder->add('uri.update', UriDescriptor::class, 'Uri to where the object can be updated');
48
        $builder->add('uri.delete', UriDescriptor::class, 'Uri to where the object can be deleted');
49
        $builder->add('uri.list', UriDescriptor::class, 'Uri to where objects of the described objects class are listed');
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getName()
56
    {
57
        return 'std';
58
    }
59
}
60