Completed
Push — master ( c34cac...3c68a7 )
by Pieter
04:47
created

DateTimePlugin::getDynamicSchemaLogic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace W2w\Lib\Apie\Plugins\DateTime;
5
6
use DateTimeInterface;
7
use Doctrine\Common\Annotations\AnnotationReader;
8
use erasys\OpenApi\Spec\v3\Schema;
9
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
10
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
11
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
12
use W2w\Lib\Apie\PluginInterfaces\NormalizerProviderInterface;
13
use W2w\Lib\Apie\PluginInterfaces\SchemaProviderInterface;
14
15
final class DateTimePlugin implements NormalizerProviderInterface, SchemaProviderInterface
16
{
17
    /**
18
     * @return NormalizerInterface[]|DenormalizerInterface[]
19
     */
20
    public function getNormalizers(): array
21
    {
22
        return [
23
            new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'])
24
        ];
25
    }
26
27
    /**
28
     * @return Schema[]
29
     */
30
    public function getDefinedStaticData(): array
31
    {
32
        AnnotationReader::addGlobalIgnoredName('alias');
33
        return [
34
            DateTimeInterface::class => new Schema(['type' => 'string', 'format' => 'date-time'])
35
        ];
36
    }
37
38
    /**
39
     * @return callable[]
40
     */
41
    public function getDynamicSchemaLogic(): array
42
    {
43
        return [];
44
    }
45
}
46