1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller; |
4
|
|
|
|
5
|
|
|
use App\Controller\BaseController; |
6
|
|
|
use App\Message\DefaultMessage; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Default Controller. |
10
|
|
|
*/ |
11
|
|
|
class DefaultController extends BaseController |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param \Slim\Container $container |
15
|
|
|
*/ |
16
|
|
|
public function __construct(\Slim\Container $container) |
17
|
|
|
{ |
18
|
|
|
$this->logger = $container->get('logger'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get Help. |
23
|
|
|
* |
24
|
|
|
* @param Request $request |
25
|
|
|
* @param Response $response |
26
|
|
|
* @param array $args |
27
|
|
|
* @return array |
28
|
|
|
*/ |
29
|
|
|
public function getHelp($request, $response, $args) |
30
|
|
|
{ |
31
|
|
|
$this->setParams($request, $response, $args); |
32
|
|
|
// $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; |
|
|
|
|
33
|
|
|
$url = 'http://localhost:8080/'; |
34
|
|
|
$message = [ |
35
|
|
|
'help' => $url . '', |
36
|
|
|
'tasks' => $url . 'tasks', |
37
|
|
|
'users' => $url . 'users', |
38
|
|
|
'version' => $url . 'version', |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
return $this->jsonResponse('success', $message, 200); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get Api Version. |
46
|
|
|
* |
47
|
|
|
* @param Request $request |
48
|
|
|
* @param Response $response |
49
|
|
|
* @param array $args |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
public function getVersion($request, $response, $args) |
53
|
|
|
{ |
54
|
|
|
$this->setParams($request, $response, $args); |
55
|
|
|
$version = [ |
56
|
|
|
'api_version' => DefaultMessage::API_VERSION |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
return $this->jsonResponse('success', $version, 200); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get Api Status. |
64
|
|
|
* |
65
|
|
|
* @param Request $request |
66
|
|
|
* @param Response $response |
67
|
|
|
* @param array $args |
68
|
|
|
* @return array |
69
|
|
|
*/ |
70
|
|
|
public function getStatus($request, $response, $args) |
71
|
|
|
{ |
72
|
|
|
$this->setParams($request, $response, $args); |
73
|
|
|
$status = [ |
74
|
|
|
'api_status' => 'OK' |
75
|
|
|
]; |
76
|
|
|
|
77
|
|
|
return $this->jsonResponse('success', $status, 200); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.