Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Setup Failed
Push — development ( b0da86...933e1e )
by José
07:54
created

DonorsQuery   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 53
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 4 1
A args() 0 17 1
A resolve() 0 21 4
1
<?php
2
3
namespace DoeSangue\GraphQL\Query;
4
5
use GraphQL;
6
use DoeSangue\Models\User;
7
use GraphQL\Type\Definition\Type;
8
use Folklore\GraphQL\Support\Query;
9
10
class DonorsQuery extends Query
11
{
12
13
  protected $attributes = [
14
    'name' => 'donors'
15
  ];
16
17
  public function type()
18
  {
19
    return Type::listOf(GraphQL::type('Donor'));
20
  }
21
22
  public function args()
23
  {
24
    return [
25
      'first_name' => ['name' => 'firs_tname', 'type' => Type::string()],
26
      'last_name' => ['name' => 'last_name', 'type' => Type::string()],
27
      'email' => ['name' => 'email', 'type' => Type::string()],
28
      'username' => ['name' => 'username', 'type' => Type::string()],
29
      'phone' => ['name' => 'phone', 'type' => Type::string()],
30
      'country_code' => ['name' => 'country_code', 'type' => Type::string()],
31
      'bio' => ['name' => 'bio', 'type' => Type::string()],
32
      'birthdate' => ['name' => 'birthdate', 'type' => Type::string()],
33
      'active' => ['name' => 'active', 'type' => Type::string()],
34
      'password' => ['name' => 'password', 'type' => Type::string()],
35
      'blood_type_id' => ['name' => 'blood_type_id', 'type' => Type::string()],
36
      'first' => ['name' => 'first', 'type' => Type::int()],
37
    ];
38
  }
39
40
  public function resolve($root,$args)
41
  {
42
    $donor = new User;
43
44
    // Limit
45
    if (isset($args['first'])) {
46
      $donor = $donor->limit($args['first'])->latest('id');
0 ignored issues
show
Documentation Bug introduced by
The method limit does not exist on object<DoeSangue\Models\User>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
47
    }
48
49
    if (isset($args['id']))
50
    {
51
      $donor = $donor->where('id', $args['id']);
52
    }
53
54
    if (isset($args['email']))
55
    {
56
      $donor = $donor->where('email', $args['email']);
57
    }
58
59
    return $donor->get();
60
  }
61
62
}
63