Passed
Push — master ( 092833...4a4786 )
by Derek Stephen
02:40
created

IndexController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
dl 0
loc 48
ccs 8
cts 22
cp 0.3636
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 4 1
A pingAction() 0 4 1
A fakeClientCallbackAction() 0 4 1
A emailAction() 0 7 1
A apiAction() 0 7 1
1
<?php
2
3
namespace App\Controller;
4
5
use Bone\Mvc\Registry;
6
use DateTime;
7
use Swagger;
8
use Zend\Diactoros\Response;
9
10
/**
11
 * @SWG\Swagger(
12
 *     schemes={"https"},
13
 *     host="awesome.scot",
14
 *     basePath="/",
15
 *     @SWG\Info(
16
 *         version="1.0.0",
17
 *         title="BONE MVC API",
18
 *         description="This be a swashbucklin' API."
19
 *     ),
20
 *     @SWG\ExternalDocumentation(
21
 *         description="By delboy1978uk",
22
 *         url="https://github.com/delboy1978uk"
23
 *     )
24
 * )
25
 *
26
 */
27
class IndexController extends BaseController
28
{
29 2
    public function indexAction()
30
    {
31 2
        $this->enableLayout();
32 2
        $this->enableView();
33 2
    }
34
35
    /**
36
     * Check basic connectivity. Returns a timestamp.
37
     * @SWG\Get(
38
     *     path="/ping",
39
     *     tags={"status"},
40
     *     @SWG\Response(response="200", description="Sends a response with the time")
41
     * )
42
     *
43
     */
44 2
    public function pingAction()
45
    {
46 2
        $date = new DateTime();
47 2
        $this->sendJsonResponse(['pong' => $date->format('Y-m-d H:i:s')]);
48 2
    }
49
50
    /**
51
     * @return Response
52
     */
53
    public function apiAction()
54
    {
55
        $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

55
        $swagger = /** @scrutinizer ignore-call */ Swagger\scan(APPLICATION_PATH.'/src')->__toString();
Loading history...
56
        $response = new Response();
57
        $response = $response->withHeader('Content-Type', 'application/json');
58
        $response->getBody()->write($swagger);
59
        return $response;
60
    }
61
62
    public function fakeClientCallbackAction()
63
    {
64
        $request = $this->getRequest();
65
        die(var_dump($request));
0 ignored issues
show
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...
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...
66
    }
67
68
    public function emailAction()
69
    {
70
        $reg = $this->getViewEngine()->render('emails/user_registration', [
71
            'siteUrl' => $this->getServerEnvironment()->getSiteURL(),
72
            'activationLink' => '/user/activate/[email protected]/dhfdhfddhfdh',
73
        ]);
74
        echo $reg; exit;
0 ignored issues
show
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...
75
    }
76
}
77