ContentBlockUnion   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 13
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypes() 0 4 1
A resolveType() 0 4 3
1
<?php
2
/**
3
 * ContentBlockUnion.php
4
 */
5
6
namespace Examples\Blog\Schema;
7
8
9
use Youshido\GraphQL\Type\Union\AbstractUnionType;
10
11
class ContentBlockUnion extends AbstractUnionType
12
{
13
    public function getTypes()
14
    {
15
        return [new PostType(), new BannerType()];
16
    }
17
18
    public function resolveType($object)
19
    {
20
        return empty($object['id']) ? null : (strpos($object['id'], 'post') !== false ? new PostType() : new BannerType());
21
    }
22
23
}
24