Passed
Push — controller-updates ( d6e495...032841 )
by Alex
02:51 queued 10s
created

JsonApiControllerActions::showRelationship()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
namespace Huntie\JsonApi\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
7
/**
8
 * Add default resource controller methods for JsonApiController actions.
9
 *
10
 * @return JsonApiController
11
 */
12
trait JsonApiControllerActions
13
{
14
    /**
15
     * Return a listing of the resource.
16
     *
17
     * @param Request $request
18
     *
19
     * @return \Huntie\JsonApi\Http\JsonApiResponse
20
     */
21
    public function index(Request $request)
22
    {
23
        return $this->indexAction($request);
0 ignored issues
show
Bug introduced by
It seems like indexAction() 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...
24
    }
25
26
    /**
27
     * Store a new record.
28
     *
29
     * @param Request $request
30
     *
31
     * @return \Huntie\JsonApi\Http\JsonApiResponse
32
     */
33
    public function store(Request $request)
34
    {
35
        return $this->storeAction($request);
0 ignored issues
show
Bug introduced by
It seems like storeAction() 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...
36
    }
37
38
    /**
39
     * Return a specified record.
40
     *
41
     * @param Request $request
42
     * @param int     $id
43
     *
44
     * @return \Huntie\JsonApi\Http\JsonApiResponse
45
     */
46
    public function show(Request $request, $id)
47
    {
48
        return $this->showAction($request, $id);
0 ignored issues
show
Bug introduced by
It seems like showAction() 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...
49
    }
50
51
    /**
52
     * Update a specified record.
53
     *
54
     * @param Request $request
55
     * @param int     $id
56
     *
57
     * @return \Huntie\JsonApi\Http\JsonApiResponse
58
     */
59
    public function update(Request $request, $id)
60
    {
61
        return $this->updateAction($request, $id);
0 ignored issues
show
Bug introduced by
The method updateAction() does not exist on Huntie\JsonApi\Http\Cont...sonApiControllerActions. Did you maybe mean update()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
62
    }
63
64
    /**
65
     * Destroy a specified record.
66
     *
67
     * @param Request $request
68
     * @param int     $id
69
     *
70
     * @return \Huntie\JsonApi\Http\JsonApiResponse
71
     */
72
    public function destroy(Request $request, $id)
73
    {
74
        return $this->destroyAction($request, $id);
0 ignored issues
show
Bug introduced by
The method destroyAction() does not exist on Huntie\JsonApi\Http\Cont...sonApiControllerActions. Did you maybe mean destroy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
75
    }
76
77
    /**
78
     * Return a specified record relationship.
79
     *
80
     * @param Request $request
81
     * @param int     $id
82
     * @param string  $relation
83
     *
84
     * @return \Huntie\JsonApi\Http\JsonApiResponse
85
     */
86
    public function showRelationship(Request $request, $id, $relation)
87
    {
88
        return $this->showRelationshipAction($request, $id, $relation);
0 ignored issues
show
Bug introduced by
The method showRelationshipAction() does not exist on Huntie\JsonApi\Http\Cont...sonApiControllerActions. Did you maybe mean showRelationship()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
89
    }
90
}
91