svilborg /
laravel-health
| 1 | <?php |
||
| 2 | namespace Health\Controllers; |
||
| 3 | |||
| 4 | use Illuminate\Routing\Controller; |
||
| 5 | use Health\Services\HealthService; |
||
| 6 | use Symfony\Component\HttpFoundation\Request; |
||
| 7 | use Health\Resources\Health; |
||
| 8 | use Illuminate\Http\Response; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Health Check Controler |
||
| 12 | */ |
||
| 13 | class HealthController extends Controller |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * |
||
| 18 | * @var HealthService |
||
| 19 | */ |
||
| 20 | private $healthService; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * |
||
| 24 | * @param HealthService $healthService |
||
| 25 | */ |
||
| 26 | public function __construct(HealthService $healthService) |
||
| 27 | { |
||
| 28 | $this->healthService = $healthService; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * |
||
| 33 | * @param Request $request |
||
| 34 | * @return \Illuminate\Http\JsonResponse |
||
| 35 | */ |
||
| 36 | public function check(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 37 | { |
||
| 38 | $health = $this->healthService->getHealth(config('health.checks', [])); |
||
| 39 | |||
| 40 | $statusCode = $health->isOk() ? Response::HTTP_OK : Response::HTTP_SERVICE_UNAVAILABLE; |
||
| 41 | |||
| 42 | $response = new Health($health); |
||
| 43 | $response->withoutWrapping(); |
||
| 44 | |||
| 45 | return $response->response()->setStatusCode($statusCode); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.