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

PostResolverMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
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\Node\Post;
16
17
use Acme\App\Core\Component\Blog\Domain\Post\PostId;
18
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Author\PostAuthorsResolver;
19
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Comment\PostCommentsResolver;
20
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Tag\PostTagsResolver;
21
use ArrayObject;
22
use GraphQL\Type\Definition\ResolveInfo;
23
use Overblog\GraphQLBundle\Definition\Argument;
24
use Overblog\GraphQLBundle\Resolver\ResolverMap as BaseResolverMap;
25
26
final class PostResolverMap extends BaseResolverMap
27
{
28
    /**
29
     * @var PostCommentsResolver
30
     */
31
    private $postCommentsResolver;
32
33
    /**
34
     * @var PostTagsResolver
35
     */
36
    private $postTagsResolver;
37
38
    /**
39
     * @var PostAuthorsResolver
40
     */
41
    private $postAuthorsResolver;
42
43
    public function __construct(
44
        PostCommentsResolver $postCommentsResolver,
45
        PostTagsResolver $postTagsResolver,
46
        PostAuthorsResolver $postAuthorsResolver
47
    ) {
48
        $this->postCommentsResolver = $postCommentsResolver;
49
        $this->postTagsResolver = $postTagsResolver;
50
        $this->postAuthorsResolver = $postAuthorsResolver;
51
    }
52
53
    protected function map(): array
54
    {
55
        return [
56
            'Post' => [
57
                'comments' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
                    return $this->postCommentsResolver->getPostCommentsConnection(new PostId($value->getId()));
59
                },
60
                'tags' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
                    return $this->postTagsResolver->getPostTagsConnection(new PostId($value->getId()));
62
                },
63
                'authors' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
                    return $this->postAuthorsResolver->getPostAuthorsConnection(new PostId($value->getId()));
65
                },
66
            ],
67
        ];
68
    }
69
}
70