| Conditions | 9 |
| Paths | 64 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function reorder(Request $request): JsonResponse |
||
| 23 | { |
||
| 24 | $data = json_decode($request->getContent() ?: '[]', true); |
||
| 25 | $courseId = isset($data['courseId']) ? (int) $data['courseId'] : null; |
||
| 26 | $sid = array_key_exists('sid', $data) ? ($data['sid'] !== null ? (int)$data['sid'] : null) : null; |
||
| 27 | $order = $data['order'] ?? $data['ids'] ?? null; |
||
| 28 | $categoryId = array_key_exists('categoryId', $data) ? ($data['categoryId'] !== null ? (int)$data['categoryId'] : null) : null; |
||
| 29 | |||
| 30 | if (!$courseId || !\is_array($order)) { |
||
|
|
|||
| 31 | return new JsonResponse(['error' => 'Invalid payload'], 400); |
||
| 32 | } |
||
| 33 | |||
| 34 | $this->lpRepo->reorderByIds($courseId, $sid, array_map('intval', $order), $categoryId); |
||
| 35 | |||
| 36 | return new JsonResponse(null, 204); |
||
| 37 | } |
||
| 39 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: