Code Duplication    Length = 38-38 lines in 2 locations

server/app/GraphQL/Mutations/AbstractMutation.php 1 location

@@ 20-57 (lines=38) @@
17
/**
18
 * Class AbstractMutation.
19
 */
20
abstract class AbstractMutation extends Mutation
21
{
22
    use HasValidation;
23
    use FeaturesSupport;
24
25
    /**
26
     * AbstractMutation 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

server/app/GraphQL/Queries/AbstractQuery.php 1 location

@@ 20-57 (lines=38) @@
17
/**
18
 * Class AbstractQuery.
19
 */
20
abstract class AbstractQuery extends Query
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