These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PragmaRX\Health\Http\Controllers; |
||
4 | |||
5 | use PragmaRX\Health\Service; |
||
6 | use Illuminate\Routing\Controller; |
||
7 | use Illuminate\Support\Facades\File; |
||
8 | |||
9 | class Health extends Controller |
||
10 | { |
||
11 | /** |
||
12 | * @var Service |
||
13 | */ |
||
14 | private $healthService; |
||
15 | |||
16 | /** |
||
17 | * Health constructor. |
||
18 | * |
||
19 | * @param Service $healthService |
||
20 | */ |
||
21 | public function __construct(Service $healthService) |
||
22 | { |
||
23 | $this->healthService = $healthService; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Check all resources. |
||
28 | * |
||
29 | * @return array |
||
30 | * @throws \Exception |
||
31 | */ |
||
32 | public function check() |
||
33 | { |
||
34 | $this->healthService->setAction('check'); |
||
35 | |||
36 | return response($this->healthService->health()); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Check and get one resource. |
||
41 | * |
||
42 | * @param $slug |
||
43 | * @return mixed |
||
44 | * @throws \Exception |
||
45 | */ |
||
46 | public function getResource($slug) |
||
47 | { |
||
48 | $this->healthService->setAction('resource'); |
||
49 | |||
50 | return $this->healthService->resource($slug); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get all resources. |
||
55 | * |
||
56 | * @return mixed |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | public function allResources() |
||
60 | { |
||
61 | return $this->healthService->getResources(); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return mixed |
||
66 | * @throws \Exception |
||
67 | */ |
||
68 | public function string() |
||
69 | { |
||
70 | $this->healthService->setAction('string'); |
||
71 | |||
72 | return response( |
||
73 | $this->healthService->string(), |
||
74 | $this->getReponseCode() |
||
0 ignored issues
–
show
|
|||
75 | ); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
80 | * @throws \Exception |
||
81 | */ |
||
82 | public function panel() |
||
83 | { |
||
84 | $this->healthService->setAction('panel'); |
||
85 | |||
86 | return response((string) view(config('health.views.panel'))); |
||
87 | } |
||
88 | |||
89 | View Code Duplication | public function assetAppJs() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
90 | { |
||
91 | $file = File::get(config('health.assets.js')); |
||
92 | |||
93 | $response = response()->make($file); |
||
94 | |||
95 | $response->header('Content-Type', 'text/css'); |
||
96 | |||
97 | return $response; |
||
98 | } |
||
99 | |||
100 | View Code Duplication | public function assetAppCss() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
101 | { |
||
102 | $file = File::get(config('health.assets.css')); |
||
103 | |||
104 | $response = response()->make($file); |
||
105 | |||
106 | $response->header('Content-Type', 'text/css'); |
||
107 | |||
108 | return $response; |
||
109 | } |
||
110 | |||
111 | public function config() |
||
112 | { |
||
113 | return config('health'); |
||
114 | } |
||
115 | } |
||
116 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: