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

LikePost::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * LikePost.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\AbstractObjectType;
12
use Youshido\GraphQL\Type\Scalar\IntType;
13
14
class LikePost extends AbstractObjectType
15
{
16
17
    /**
18
     * @param null  $value
19
     * @param array $args
20
     * @param PostType  $type
21
     * @return mixed
22
     */
23
    public function resolve($value = null, $args = [], $type = null)
24
    {
25
        return $type->resolve($value, $args);
0 ignored issues
show
Bug introduced by
It seems like $type is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
26
    }
27
28
    public function getType()
29
    {
30
        return new PostType();
31
    }
32
33
    public function build(TypeConfigInterface $config)
34
    {
35
        $config->addArgument('id', new NonNullType(new IntType()));
36
    }
37
38
}
39