| Conditions | 5 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function wallAnswerCount(string $postIds): ?string |
||
| 30 | { |
||
| 31 | // set header |
||
| 32 | $this->setJsonHeader(); |
||
| 33 | // check query length |
||
| 34 | if (Any::isEmpty($postIds)) { |
||
| 35 | throw new NativeException('Wrong input count'); |
||
| 36 | } |
||
| 37 | |||
| 38 | $list = explode(',', $postIds); |
||
| 39 | $itemCount = count($list); |
||
| 40 | // empty or is biggest then limit? |
||
| 41 | if ($itemCount < 1 || $itemCount > self::ITEM_PER_PAGE) { |
||
| 42 | throw new NativeException('Wrong input count'); |
||
| 43 | } |
||
| 44 | |||
| 45 | // prepare response |
||
| 46 | $response = []; |
||
| 47 | foreach ($list as $post) { |
||
| 48 | $response[$post] = WallAnswer::where('post_id', $post)->count(); |
||
| 49 | } |
||
| 50 | |||
| 51 | // display json data |
||
| 52 | return json_encode([ |
||
| 53 | 'status' => 1, |
||
| 54 | 'data' => $response |
||
| 55 | ]); |
||
| 56 | } |
||
| 57 | } |
||
| 58 |