HealthController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 10 2
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
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
    public function check(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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