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

AbstractQuery::queryFor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 4
loc 4
rs 10
c 0
b 0
f 0
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\Queries;
10
11
use Folklore\GraphQL\Support\Query;
12
use Illuminate\Database\Eloquent\Model;
13
use Illuminate\Database\Eloquent\Builder;
14
use App\GraphQL\Queries\Support\HasValidation;
15
use App\GraphQL\Feature\Kernel\FeaturesSupport;
16
17
/**
18
 * Class AbstractQuery.
19
 */
20 View Code Duplication
abstract class AbstractQuery extends Query
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    use HasValidation;
23
    use FeaturesSupport;
24
25
    /**
26
     * AbstractQuery constructor.
27
     * @param array $attributes
28
     */
29
    public function __construct($attributes = [])
30
    {
31
        $this->boot();
32
        parent::__construct($attributes);
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function args(): array
39
    {
40
        return $this->extendArguments($this->queryArguments());
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    abstract protected function queryArguments(): array;
47
48
    /**
49
     * @param string|Model $model
50
     * @param array  $args
51
     * @return Builder|Model <T>
52
     */
53
    protected function queryFor(string $model, array $args = []): Builder
54
    {
55
        return $this->extendQuery($model::query(), $args);
56
    }
57
}
58