Test Setup Failed
Push — graphql_api ( 4ff753 )
by Herberto
07:48 queued 01:35
created

AtomDateTimeResolverMap   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Explicit Architecture POC,
7
 * which is created on top of the Symfony Demo application.
8
 *
9
 * (c) Herberto Graça <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Acme\App\Presentation\Api\GraphQl\Scalar;
16
17
use DateTimeImmutable;
18
use DateTimeInterface;
19
use GraphQL\Language\AST\StringValueNode;
20
use Overblog\GraphQLBundle\Resolver\ResolverMap as BaseResolverMap;
21
22
final class AtomDateTimeResolverMap extends BaseResolverMap
23
{
24
    protected function map(): array
25
    {
26
        return [
27
            'AtomDateTime' => [
28
                self::SERIALIZE => function (DateTimeInterface $value) {
29
                    return $value->format(DateTimeInterface::ATOM);
30
                },
31
                self::PARSE_VALUE => function (string $value) {
32
                    return new DateTimeImmutable($value);
33
                },
34
                self::PARSE_LITERAL => function (StringValueNode $valueNode) {
35
                    return new DateTimeImmutable($valueNode->value);
36
                },
37
            ],
38
        ];
39
    }
40
}
41