Code Duplication    Length = 38-40 lines in 4 locations

app/GraphQL/Queries/DocsQuery.php 1 location

@@ 21-59 (lines=39) @@
18
/**
19
 * Class DocsQuery.
20
 */
21
class DocsQuery extends AbstractQuery
22
{
23
    /**
24
     * @var array
25
     */
26
    protected $attributes = [
27
        'name'        => 'Docs list query',
28
        'description' => 'Returns a list of available documentation repositories',
29
    ];
30
31
    /**
32
     * @return ListOfType
33
     */
34
    public function type(): ListOfType
35
    {
36
        return Type::listOf(\GraphQL::type(DocsType::getName()));
37
    }
38
39
    /**
40
     * @return array
41
     */
42
    protected function queryArguments(): array
43
    {
44
        return [];
45
    }
46
47
    /**
48
     * @param $root
49
     * @param  array      $args
50
     * @return Collection
51
     */
52
    public function resolve($root, array $args = []): Collection
53
    {
54
        $query = $this->queryFor(Docs::class, $args)
55
            ->with('pages');
56
57
        return DocsSerializer::collection($query->get());
58
    }
59
}
60

app/GraphQL/Queries/TagsQuery.php 1 location

@@ 23-60 (lines=38) @@
20
/**
21
 * Class TagsQuery.
22
 */
23
class TagsQuery extends AbstractQuery
24
{
25
    /**
26
     * @var array
27
     */
28
    protected $attributes = [
29
        'name'        => 'Tags list query',
30
        'description' => 'Returns a list of available tags',
31
    ];
32
33
    /**
34
     * @return ListOfType
35
     */
36
    public function type(): ListOfType
37
    {
38
        return Type::listOf(\GraphQL::type(TagType::getName()));
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    protected function queryArguments(): array
45
    {
46
        return [];
47
    }
48
49
    /**
50
     * @param $root
51
     * @param  array      $args
52
     * @return Collection
53
     */
54
    public function resolve($root, array $args = []): Collection
55
    {
56
        $query = $this->queryFor(Tag::class, $args);
57
58
        return TagSerializer::collection($query->get());
59
    }
60
}
61

app/GraphQL/Queries/TipsQuery.php 1 location

@@ 23-62 (lines=40) @@
20
/**
21
 * Class TipsQuery.
22
 */
23
class TipsQuery extends AbstractQuery
24
{
25
    /**
26
     * @var array
27
     */
28
    protected $attributes = [
29
        'name'        => 'Tips list query',
30
        'description' => 'Returns a list of available tips',
31
    ];
32
33
    /**
34
     * @return ListOfType
35
     */
36
    public function type(): ListOfType
37
    {
38
        return Type::listOf(\GraphQL::type(TipType::getName()));
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    protected function queryArguments(): array
45
    {
46
        return [];
47
    }
48
49
    /**
50
     * @param             $root
51
     * @param  array      $args
52
     * @return Collection
53
     */
54
    public function resolve($root, array $args = []): Collection
55
    {
56
        /** @var Builder $query */
57
        $query = $this->queryFor(Tip::class, $args)
58
            ->with('likes', 'dislikes', 'user');
59
60
        return TipSerializer::collection($query->get());
61
    }
62
}
63

app/GraphQL/Queries/UsersQuery.php 1 location

@@ 22-59 (lines=38) @@
19
/**
20
 * Class UsersQuery.
21
 */
22
class UsersQuery extends AbstractQuery
23
{
24
    /**
25
     * @var array
26
     */
27
    protected $attributes = [
28
        'name'        => 'Users list query',
29
        'description' => 'Returns a list of users',
30
    ];
31
32
    /**
33
     * @return ListOfType
34
     */
35
    public function type(): ListOfType
36
    {
37
        return Type::listOf(\GraphQL::type(UserType::getName()));
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    protected function queryArguments(): array
44
    {
45
        return [];
46
    }
47
48
    /**
49
     * @param        $root
50
     * @param  array $args
51
     * @return Collection
52
     */
53
    public function resolve($root, array $args = []): Collection
54
    {
55
        $query = $this->queryFor(User::class, $args);
56
57
        return UserSerializer::collection($query->get());
58
    }
59
}
60