Completed
Push — master ( f8702a...461e07 )
by Alexandr
04:08
created

ContentBlockInterface::resolveType()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 3
eloc 2
nc 4
nop 1
1
<?php
2
/**
3
 * ContentBlockInterface.php
4
 */
5
6
namespace Examples\Blog\Schema;
7
8
9
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
10
use Youshido\GraphQL\Type\NonNullType;
11
use Youshido\GraphQL\Type\Object\AbstractInterfaceType;
12
use Youshido\GraphQL\Type\Scalar\StringType;
13
14
class ContentBlockInterface extends AbstractInterfaceType
15
{
16
17
    public function build(TypeConfigInterface $config)
18
    {
19
        $config->addField('title', new NonNullType(new StringType()));
20
        $config->addField('summary', new StringType());
21
    }
22
23
    public function resolveType($object)
24
    {
25
        return empty($object['id']) ? null : (strpos($object['id'], 'post') !== false ? new PostType() : new BannerType());
26
    }
27
}
28