These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of laravel.su package. |
||
5 | * |
||
6 | * For the full copyright and license information, please view the LICENSE |
||
7 | * file that was distributed with this source code. |
||
8 | */ |
||
9 | declare(strict_types=1); |
||
10 | |||
11 | namespace App\GraphQL\Queries; |
||
12 | |||
13 | use App\Models\Article; |
||
14 | use App\GraphQL\Kernel\Paginator; |
||
15 | use GraphQL\Type\Definition\Type; |
||
16 | use GraphQL\Type\Definition\ListOfType; |
||
17 | use Illuminate\Contracts\Support\Arrayable; |
||
18 | use App\GraphQL\Serializers\ArticleSerializer; |
||
19 | |||
20 | /** |
||
21 | * Class ArticlesQuery. |
||
22 | */ |
||
23 | class ArticlesQuery extends AbstractQuery |
||
24 | { |
||
25 | use Paginator; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $attributes = [ |
||
31 | 'name' => 'Article list query', |
||
32 | 'description' => 'Returns a list of available articles', |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * @return ListOfType |
||
37 | */ |
||
38 | public function type(): ListOfType |
||
39 | { |
||
40 | return Type::listOf(\GraphQL::type('Article')); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return array |
||
45 | */ |
||
46 | protected function queryArguments(): array |
||
47 | { |
||
48 | return Paginator\PaginatorConfiguration::withPaginatorArguments([ |
||
49 | |||
50 | ]); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param $root |
||
55 | * @param array $args |
||
56 | * @return \Traversable |
||
57 | */ |
||
58 | public function resolve($root, array $args = []): \Traversable |
||
0 ignored issues
–
show
|
|||
59 | { |
||
60 | $query = $this->queryFor(Article::class, $args); |
||
61 | |||
62 | $count = $query->published()->count(); |
||
63 | $query = $query->latestPublished(); |
||
64 | |||
65 | return $this->paginate($query, $count) |
||
66 | ->withArgs($args) |
||
67 | ->use(ArticleSerializer::class) |
||
68 | ->as('articles'); |
||
69 | } |
||
70 | } |
||
71 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.