GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( e7bef7...3cccd4 )
by Šimon
03:07
created

UserType::resolvePhoto()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
namespace GraphQL\Examples\Blog\Type;
3
4
use GraphQL\Examples\Blog\AppContext;
5
use GraphQL\Examples\Blog\Data\DataSource;
6
use GraphQL\Examples\Blog\Data\User;
7
use GraphQL\Examples\Blog\Types;
8
use GraphQL\Type\Definition\ObjectType;
9
use GraphQL\Type\Definition\ResolveInfo;
10
11
class UserType extends ObjectType
12
{
13
    public function __construct()
14
    {
15
        $config = [
16
            'name' => 'User',
17
            'description' => 'Our blog authors',
18
            'fields' => function() {
19
                return [
20
                    'id' => Types::id(),
21
                    'email' => Types::email(),
22
                    'photo' => [
23
                        'type' => Types::image(),
24
                        'description' => 'User photo URL',
25
                        'args' => [
26
                            'size' => Types::nonNull(Types::imageSizeEnum()),
27
                        ]
28
                    ],
29
                    'firstName' => [
30
                        'type' => Types::string(),
31
                    ],
32
                    'lastName' => [
33
                        'type' => Types::string(),
34
                    ],
35
                    'lastStoryPosted' => Types::story(),
36
                    'fieldWithError' => [
37
                        'type' => Types::string(),
38
                        'resolve' => function() {
39
                            throw new \Exception("This is error field");
40
                        }
41
                    ]
42
                ];
43
            },
44
            'interfaces' => [
45
                Types::node()
46
            ],
47
            'resolveField' => function($user, $args, $context, ResolveInfo $info) {
48
                $method = 'resolve' . ucfirst($info->fieldName);
49
                if (method_exists($this, $method)) {
50
                    return $this->{$method}($user, $args, $context, $info);
51
                } else {
52
                    return $user->{$info->fieldName};
53
                }
54
            }
55
        ];
56
        parent::__construct($config);
57
    }
58
59
    public function resolvePhoto(User $user, $args)
60
    {
61
        return DataSource::getUserPhoto($user->id, $args['size']);
62
    }
63
64
    public function resolveLastStoryPosted(User $user)
65
    {
66
        return DataSource::findLastStoryFor($user->id);
67
    }
68
}
69