MediaFileSchema::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace App\Schema;
3
4
use \Carbon\Carbon;
5
6
/**
7
 * @api {get} /media-file List of media-file
8
 * @apiName GetMediaFiles
9
 * @apiGroup MediaFile
10
 *
11
 * @apiDescription Get list of media-file
12
 *
13
 * @apiPermission admin
14
 * @apiHeader {String} Authorization Bearer TOKEN
15
 * @apiUse UnauthorizedError
16
 *
17
 * @apiSuccessExample {json} Success (200)
18
 *     HTTP/1.1 200 OK
19
 *     {
20
 *       "data": [
21
 *         {
22
 *           "type": "media-file",
23
 *           "id": "1",
24
 *           "attributes": {
25
 *             "file": "String",
26
 *             "file_info": "String",
27
 *             "created_by": 1,
28
 *             "updated_by": 1,
29
 *             "created_at": "2016-10-17T07:38:21+0000",
30
 *             "updated_at": "2016-10-17T07:38:21+0000"
31
 *           },
32
 *           "links": {
33
 *             "self": "/media-file/1"
34
 *           }
35
 *         }
36
 *       ]
37
 *     }
38
 *
39
 * @apiUse StandardErrors
40
 */
41
42
/**
43
 * @api {get} /media-file/:id Get media-file
44
 * @apiName GetMediaFile
45
 * @apiGroup MediaFile
46
 *
47
 * @apiDescription Get media-file.
48
 *
49
 * @apiPermission admin
50
 * @apiHeader {String} Authorization Bearer TOKEN
51
 * @apiUse UnauthorizedError
52
 *
53
 * @apiParam {Number} id Id media-file
54
 *
55
 * @apiSuccessExample {json} Success (200)
56
 *     HTTP/1.1 200 OK
57
 *     {
58
 *       "data": {
59
 *         "type": "media-file",
60
 *         "id": "1",
61
 *         "attributes": {
62
 *             "file": "String",
63
 *             "file_info": "String",
64
 *             "created_by": 1,
65
 *             "updated_by": 1,
66
 *             "created_at": "2016-10-17T07:38:21+0000",
67
 *             "updated_at": "2016-10-17T07:38:21+0000"
68
 *         },
69
 *         "links": {
70
 *           "self": "/media-file/1"
71
 *         }
72
 *       }
73
 *     }
74
 *
75
 * @apiUse StandardErrors
76
 * @apiUse NotFoundError
77
 */
78
79
/**
80
 * @api {delete} /media-file/:id Delete media-file
81
 * @apiName DeleteMediaFile
82
 * @apiGroup MediaFile
83
 *
84
 * @apiDescription Delete media-file.
85
 *
86
 * @apiPermission admin
87
 * @apiHeader {String} Authorization Bearer TOKEN
88
 * @apiUse UnauthorizedError
89
 *
90
 * @apiParam {Number} id Id media-file
91
 *
92
 * @apiSuccessExample {json} Success (204)
93
 *     HTTP/1.1 204 OK
94
 *
95
 * @apiUse StandardErrors
96
 * @apiUse NotFoundError
97
 */
98
99 View Code Duplication
final class MediaFileSchema extends BaseSchema
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...
100
{
101
    protected $resourceType = 'media-file';
102
103
    public function getId($entity)
104
    {
105
        return $entity->id;
106
    }
107
108
    public function getAttributes($entity)
109
    {
110
        return [
111
            'file'       => (string)$entity->file,
112
            'file_info'  => json_decode($entity->file_info),
113
            'created_by' => (integer)$entity->created_by,
114
            'updated_by' => (integer)$entity->updated_by,
115
            'created_at' => Carbon::parse($entity->created_at)->setTimezone('UTC')->format(Carbon::ISO8601),
116
            'updated_at' => Carbon::parse($entity->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601),
117
        ];
118
    }
119
}
120