Passed
Push — master ( 1554de...83447c )
by Mauro
02:38
created

src/Controller/DefaultController.php (1 issue)

Upgrade to new PHP Analysis Engine

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 App\Controller;
4
5
use App\Message\DefaultMessage;
6
use Slim\Container;
7
use Slim\Http\Request;
8
use Slim\Http\Response;
9
10
/**
11
 * Default Controller.
12
 */
13
class DefaultController extends BaseController
14
{
15
    /**
16
     * @param Container $container
17
     */
18
    public function __construct(Container $container)
19
    {
20
        $this->logger = $container->get('logger');
21
    }
22
23
    /**
24
     * Get Help.
25
     *
26
     * @param Request $request
27
     * @param Response $response
28
     * @param array $args
29
     * @return Response
30
     */
31
    public function getHelp($request, $response, $args)
32
    {
33
        $this->setParams($request, $response, $args);
34
//        $protocol = ($_SERVER['HTTP_X_FORWARDED_PORT'] == 443) ? "https://" : "http://";
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
35
//        $domainName = $_SERVER['HTTP_HOST'] . '/';
36
//        $url = $protocol . $domainName;
37
        $url = '/';
38
        $message = [
39
            'tasks' => $url . 'api/v1/tasks',
40
            'users' => $url . 'api/v1/users',
41
            'status' => $url . 'status',
42
            'version' => $url . 'version',
43
            'this help' => $url . '',
44
        ];
45
46
        return $this->jsonResponse('success', $message, 200);
47
    }
48
49
    /**
50
     * Get Api Version.
51
     *
52
     * @param Request $request
53
     * @param Response $response
54
     * @param array $args
55
     * @return Response
56
     */
57
    public function getVersion($request, $response, $args)
58
    {
59
        $this->setParams($request, $response, $args);
60
        $version = [
61
            'version' => DefaultMessage::API_VERSION,
62
        ];
63
64
        return $this->jsonResponse('success', $version, 200);
65
    }
66
67
    /**
68
     * Get Api Status.
69
     *
70
     * @param Request $request
71
     * @param Response $response
72
     * @param array $args
73
     * @return Response
74
     */
75
    public function getStatus($request, $response, $args)
76
    {
77
        $this->setParams($request, $response, $args);
78
        $status = [
79
            'status' => 'OK',
80
        ];
81
82
        return $this->jsonResponse('success', $status, 200);
83
    }
84
}
85