| Conditions | 5 |
| Paths | 2 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | protected function getFileResponses(array $tags) |
||
| 34 | { |
||
| 35 | $responseFileTags = array_filter($tags, function ($tag) { |
||
| 36 | return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; |
||
| 37 | }); |
||
| 38 | |||
| 39 | if (empty($responseFileTags)) { |
||
| 40 | return null; |
||
| 41 | } |
||
| 42 | |||
| 43 | return array_map(function (Tag $responseFileTag) { |
||
| 44 | preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseFileTag->getContent(), $result); |
||
| 45 | |||
| 46 | $status = $result[1] ?: 200; |
||
| 47 | $content = $result[2] ? file_get_contents(storage_path($result[2]), true) : '{}'; |
||
| 48 | |||
| 49 | return new JsonResponse(json_decode($content, true), (int) $status); |
||
| 50 | }, $responseFileTags); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |