Passed
Push — master ( 51edae...d29a9b )
by Curtis
11:52 queued 05:54
created

File::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 13
rs 9.9
1
<?php
2
3
namespace App\Http\Resources\enso\files;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use App\Http\Resources\enso\core\User;
7
8
class File extends JsonResource
9
{
10
    /**
11
     * Transform the resource into an array.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @return array
15
     */
16
    public function toArray($request)
17
    {
18
        return [
19
            'id' => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on App\Http\Resources\enso\files\File. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
            'name' => $this->original_name,
0 ignored issues
show
Bug Best Practice introduced by
The property original_name does not exist on App\Http\Resources\enso\files\File. Since you implemented __get, consider adding a @property annotation.
Loading history...
21
            'size' => $this->size,
0 ignored issues
show
Bug Best Practice introduced by
The property size does not exist on App\Http\Resources\enso\files\File. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
            'mimeType' => $this->mime_type,
0 ignored issues
show
Bug Best Practice introduced by
The property mime_type does not exist on App\Http\Resources\enso\files\File. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
            'type' => $this->type(),
0 ignored issues
show
Bug introduced by
The method type() does not exist on App\Http\Resources\enso\files\File. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            'type' => $this->/** @scrutinizer ignore-call */ type(),
Loading history...
24
            'owner' => new User($this->whenLoaded('createdBy')),
25
            'isDestroyable' => $this->destroyableBy($request->user()),
0 ignored issues
show
Bug introduced by
The method destroyableBy() does not exist on App\Http\Resources\enso\files\File. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            'isDestroyable' => $this->/** @scrutinizer ignore-call */ destroyableBy($request->user()),
Loading history...
26
            'isShareable' => $this->shareableBy($request->user()),
0 ignored issues
show
Bug introduced by
The method shareableBy() does not exist on App\Http\Resources\enso\files\File. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            'isShareable' => $this->/** @scrutinizer ignore-call */ shareableBy($request->user()),
Loading history...
27
            'isViewable' => $this->viewableBy($request->user()),
0 ignored issues
show
Bug introduced by
The method viewableBy() does not exist on App\Http\Resources\enso\files\File. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            'isViewable' => $this->/** @scrutinizer ignore-call */ viewableBy($request->user()),
Loading history...
28
            'createdAt' => $this->created_at->toDatetimeString(),
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on App\Http\Resources\enso\files\File. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
        ];
30
    }
31
}
32