Passed
Push — master ( e7bef7...3228c5 )
by Vladimir
03:06
created

SearchResultType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 21
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 3
1
<?php
2
namespace GraphQL\Examples\Blog\Type;
3
4
use GraphQL\Examples\Blog\Data\Story;
5
use GraphQL\Examples\Blog\Data\User;
6
use GraphQL\Examples\Blog\Types;
7
use GraphQL\Type\Definition\UnionType;
8
9
class SearchResultType extends UnionType
10
{
11
    public function __construct()
12
    {
13
        $config = [
14
            'name' => 'SearchResultType',
15
            'types' => function() {
16
                return [
17
                    Types::story(),
18
                    Types::user()
19
                ];
20
            },
21
            'resolveType' => function($value) {
22
                if ($value instanceof Story) {
23
                    return Types::story();
24
                } else if ($value instanceof User) {
25
                    return Types::user();
26
                }
27
            }
28
        ];
29
        parent::__construct($config);
30
    }
31
}
32