1 | <?php |
||||
2 | |||||
3 | namespace VGirol\JsonApi\Resources; |
||||
4 | |||||
5 | use Illuminate\Http\Request; |
||||
6 | use VGirol\JsonApiConstant\Members; |
||||
7 | |||||
8 | class ResourceIdentifier extends BaseResource |
||||
9 | { |
||||
10 | use IsData; |
||||
11 | use IsRelationship; |
||||
12 | use HasIdentification; |
||||
13 | |||||
14 | public function __construct($resource) |
||||
15 | { |
||||
16 | parent::__construct($resource); |
||||
17 | |||||
18 | $this->wrap(Members::DATA); |
||||
19 | } |
||||
20 | |||||
21 | /** |
||||
22 | * Transform the resource into an array. |
||||
23 | * |
||||
24 | * @param Request $request |
||||
25 | * @return array |
||||
26 | */ |
||||
27 | public function toArray($request): ?array |
||||
28 | { |
||||
29 | if (is_null($this->resource)) { |
||||
30 | if ($this->isResolving) { |
||||
31 | return $this->resultingArray = [static::$wrap => null]; |
||||
32 | } else { |
||||
33 | return $this->resultingArray = null; |
||||
34 | } |
||||
35 | } |
||||
36 | |||||
37 | // Set identification (i.e., resource type and id) |
||||
38 | $this->setIdentification($request); |
||||
39 | |||||
40 | // Add meta |
||||
41 | $this->setMeta($request); |
||||
42 | |||||
43 | return $this->resultingArray; |
||||
44 | } |
||||
45 | |||||
46 | /** |
||||
47 | * Get any additional data that should be returned with the resource array. |
||||
48 | * |
||||
49 | * @param Request $request |
||||
50 | * @return array |
||||
51 | */ |
||||
52 | public function with($request) |
||||
53 | { |
||||
54 | // Top-level links member |
||||
55 | if ($request->method() != 'POST') { |
||||
0 ignored issues
–
show
|
|||||
56 | $this->addDocumentLink(Members::LINK_SELF, $this->getDocumentSelfLink($request)); |
||||
0 ignored issues
–
show
$request of type Illuminate\Http\Request is incompatible with the type Illuminate\Support\Facades\Request expected by parameter $request of VGirol\JsonApi\Resources...::getDocumentSelfLink() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
57 | $this->addDocumentLink(Members::LINK_RELATED, $this->getDocumentRelatedLink($request)); |
||||
0 ignored issues
–
show
$request of type Illuminate\Http\Request is incompatible with the type Illuminate\Support\Facades\Request expected by parameter $request of VGirol\JsonApi\Resources...etDocumentRelatedLink() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
58 | } |
||||
59 | |||||
60 | return $this->with; |
||||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Could be overloaded |
||||
65 | * |
||||
66 | * @param Request $request |
||||
67 | * |
||||
68 | * @return void |
||||
69 | */ |
||||
70 | protected function setMeta($request) |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
71 | { |
||||
72 | // $this->addResourceMeta('key', 'value'); |
||||
73 | } |
||||
74 | } |
||||
75 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.