Completed
Push — master ( d14457...da0e1e )
by Derek Stephen
25:25 queued 19:55
created

IndexController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Controller;
4
5
use DateTime;
6
use Swagger;
7
use Zend\Diactoros\Response;
8
9
/**
10
 * @SWG\Swagger(
11
 *     schemes={"https"},
12
 *     host="awesome.scot",
13
 *     basePath="/",
14
 *     @SWG\Info(
15
 *         version="1.0.0",
16
 *         title="BONE MVC API",
17
 *         description="This be a swashbucklin' API."
18
 *     ),
19
 *     @SWG\ExternalDocumentation(
20
 *         description="By delboy1978uk",
21
 *         url="https://github.com/delboy1978uk"
22
 *     )
23
 * )
24
 *
25
 */
26
class IndexController extends BaseController
27
{
28
    public function indexAction()
29
    {
30
        $this->enableLayout();
31
        $this->enableView();
32
    }
33
34
    /**
35
     * Check basic connectivity. Returns a timestamp.
36
     * @SWG\Get(
37
     *     path="/ping",
38
     *     tags={"status"},
39
     *     @SWG\Response(response="200", description="Sends a response with the time")
40
     * )
41
     *
42
     */
43 1
    public function pingAction()
44
    {
45 1
        $date = new DateTime();
46 1
        $this->sendJsonResponse(['pong' => $date->format('Y-m-d H:i:s')]);
47 1
    }
48
49
    /**
50
     * @return Response
51
     */
52
    public function apiAction()
53
    {
54
        $swagger = Swagger\scan(APPLICATION_PATH.'/src')->__toString();
0 ignored issues
show
Bug introduced by
The function scan was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

54
        $swagger = /** @scrutinizer ignore-call */ Swagger\scan(APPLICATION_PATH.'/src')->__toString();
Loading history...
55
        $response = new Response();
56
        $response = $response->withHeader('Content-Type', 'application/json');
57
        $response->getBody()->write($swagger);
58
        return $response;
59
    }
60
61
    public function fakeClientCallbackAction()
62
    {
63
        $request = $this->getRequest();
64
        die(var_dump($request));
0 ignored issues
show
Bug introduced by
Are you sure the usage of var_dump($request) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
Security Debugging Code introduced by
var_dump($request) looks like debug code. Are you sure you do not want to remove it?
Loading history...
65
    }
66
}
67