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

LikePost   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 3
c 5
b 1
f 0
lcom 0
cbo 5
dl 0
loc 25
rs 10

3 Methods

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