HierarchyExtension::buildSchema()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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\BooleanDescriptor;
10
use Psi\Component\Description\Descriptor\ArrayDescriptor;
11
use Psi\Component\Description\Descriptor\UriCollectionDescriptor;
12
13
/**
14
 * Standard extension for providing hierarchical descriptors.
15
 *
16
 * Can be applied to file systems, hierarchical databases, etc.
17
 */
18
class HierarchyExtension implements ExtensionInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function buildSchema(Builder $builder)
24
    {
25
        $builder->add('allow_children', BooleanDescriptor::class, 'This class is allowed to have children');
26
        $builder->add('children_types', ArrayDescriptor::class, 'Valid children types');
27
        $builder->add('uris.create_child', UriCollectionDescriptor::class, 'Collection of URLs where children can be created (keys are the child types)');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getName()
34
    {
35
        return 'hierarchy';
36
    }
37
}
38