1 | <?php |
||
29 | trait JsonHelper |
||
30 | { |
||
31 | /** |
||
32 | * Send something as JSON |
||
33 | * |
||
34 | * @param $response - The response |
||
35 | * @param $payload - The object to serialize |
||
36 | * @return - The JSON response |
||
|
|||
37 | */ |
||
38 | 9 | protected function sendJson(Response $response, $payload): Response |
|
43 | |||
44 | /** |
||
45 | * Sends a Content-Range header for pagination |
||
46 | * |
||
47 | * @param $response - The response |
||
48 | * @return - The JSON response |
||
49 | * @since 0.6.0 |
||
50 | */ |
||
51 | 6 | protected function sendItems(Response $response, iterable $items, ?Pagination $pagination = null, ?int $total = null): Response |
|
69 | |||
70 | /** |
||
71 | * Send notice that an entity was created. |
||
72 | * |
||
73 | * @param $response - The response |
||
74 | * @param $type - The entity type |
||
75 | * @param array<string> $ids The entity ids |
||
76 | * @param array<string,mixed> $extra Any extra data to serialize |
||
77 | * @return - The JSON response |
||
78 | */ |
||
79 | 1 | protected function sendCreated(Response $response, string $type, array $ids, array $extra = []): Response |
|
84 | |||
85 | /** |
||
86 | * Send notice that objects were deleted. |
||
87 | * |
||
88 | * @param $response - The response |
||
89 | * @param $type - The entity type |
||
90 | * @param array<string> $ids The entity ids |
||
91 | * @param array<string,mixed> $extra Any extra data to serialize |
||
92 | * @return - The JSON response |
||
93 | */ |
||
94 | 1 | protected function sendDeleted(Response $response, string $type, array $ids, array $extra = []): Response |
|
98 | |||
99 | /** |
||
100 | * Send notice that objects were updated. |
||
101 | * |
||
102 | * @param $response - The response |
||
103 | * @param $type - The entity type |
||
104 | * @param array<string> $ids The entity ids |
||
105 | * @param array<string,mixed> $extra Any extra data to serialize |
||
106 | * @return - The JSON response |
||
107 | */ |
||
108 | 1 | protected function sendUpdated(Response $response, string $type, array $ids, array $extra = []): Response |
|
112 | |||
113 | /** |
||
114 | * Sends a generic notice that objects have been operated on |
||
115 | * |
||
116 | * @param $verb - The verb |
||
117 | * @param $response - The response |
||
118 | * @param $type - The entity type |
||
119 | * @param array<string> $ids The entity ids |
||
120 | * @param array<string,mixed> $extra Any extra data to serialize |
||
121 | * @return - The JSON response |
||
122 | */ |
||
123 | 3 | protected function sendVerb(string $verb, Response $response, string $type, array $ids, array $extra = []): Response |
|
133 | } |
||
134 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.