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

ContentBlockInterface   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 6
dl 0
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 5 1
A resolveType() 0 4 3
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