Completed
Push — 2.0 ( d39b3c...f2914f )
by Kirill
02:52
created

SelectById   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootSelectById() 0 8 1
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace App\GraphQL\Feature;
10
11
use GraphQL\Type\Definition\Type;
12
use Illuminate\Database\Eloquent\Builder;
13
use App\GraphQL\Feature\Kernel\FeaturesSupport;
14
15
/**
16
 * Class SelectById
17
 * @package App\GraphQL\Feature
18
 * @mixin FeaturesSupport
19
 */
20
trait SelectById
21
{
22
    /**
23
     * @return void
24
     */
25
    protected function bootSelectById()
26
    {
27
        $this->addArgument('id', Type::listOf(Type::id()));
0 ignored issues
show
Bug introduced by
It seems like addArgument() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
28
29
        $this->addQueryFor('id', function (Builder $builder, array $ids) {
0 ignored issues
show
Bug introduced by
It seems like addQueryFor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
30
            return $builder->whereIn('id', $ids);
31
        });
32
    }
33
}