Completed
Push — master ( 638b8d...de83b5 )
by John
01:47 queued 17s
created

ArrayFactory::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Hydrator package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\PhpApi\Hydrator\Processors\Factory;
10
11
use KleijnWeb\PhpApi\Descriptions\Description\Schema\ArraySchema;
12
use KleijnWeb\PhpApi\Descriptions\Description\Schema\Schema;
13
use KleijnWeb\PhpApi\Hydrator\ProcessorBuilder;
14
use KleijnWeb\PhpApi\Hydrator\Processors\ArrayProcessor;
15
use KleijnWeb\PhpApi\Hydrator\Processors\Processor;
16
17
/**
18
 * @author John Kleijn <[email protected]>
19
 */
20
class ArrayFactory implements Factory
21
{
22
    const PRIORITY = 800;
23
24
    /**
25
     * @param Schema           $schema
26
     * @param ProcessorBuilder $builder
27
     * @return Processor|null
28
     */
29
    public function create(Schema $schema, ProcessorBuilder $builder)
30
    {
31
        if (!$schema instanceof ArraySchema) {
32
            return null;
33
        }
34
35
        return (new ArrayProcessor($schema))
36
            ->setItemsProcessor($builder->build($schema->getItemsSchema()));
37
    }
38
39
    /**
40
     * @return int
41
     */
42
    public function getPriority(): int
43
    {
44
        return self::PRIORITY;
45
    }
46
}
47