IndexController::indexAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Controller;
4
5
use DateTime;
6
use OpenApi;
7
use Zend\Diactoros\Response;
8
9
/**
10
 * @OA\OpenApi(
11
 *     schemes={"https"},
12
 *     host="awesome.scot",
13
 *     basePath="/",
14
 *     @OA\Info(
15
 *         version="1.0.0",
16
 *         title="BONE MVC API",
17
 *         description="This be a swashbucklin' API."
18
 *     ),
19
 *     @OA\ExternalDocumentation(
20
 *         description="By delboy1978uk",
21
 *         url="https://github.com/delboy1978uk"
22
 *     ),
23
 *     @OA\SecurityScheme(
24
 *         securityDefinition="oauth2",
25
 *         type="oauth2",
26
 *         description="OAuth2 Connectivity",
27
 *         flow="implicit",
28
 *         authorizationUrl="https://awesome.scot/oauth2/authorize",
29
 *         tokenUrl="https://awesome.scot/oauth2/token",
30
 *         scopes={
31
 *             admin="Admin scope.",
32
 *             test_scope="Test scope."
33
 *         }
34
 *     )
35
 * )
36
 *
37
 */
38
class IndexController extends BaseController
39
{
40 2
    public function indexAction()
41
    {
42 2
        $this->enableLayout();
43 2
        $this->enableView();
44 2
    }
45
46
    /**
47
     * Check basic connectivity. Returns a timestamp.
48
     * @OA\Get(
49
     *     path="/ping",
50
     *     tags={"status"},
51
     *     @OA\Response(response="200", description="Sends a response with the time")
52
     * )
53
     *
54
     */
55 2
    public function pingAction()
56
    {
57 2
        $date = new DateTime();
58 2
        $this->sendJsonResponse(['pong' => $date->format('Y-m-d H:i:s')]);
59 2
    }
60
61
    /**
62
     * @return Response
63
     */
64
    public function apiAction()
65
    {
66
        $swagger = OpenApi\scan(APPLICATION_PATH.'/src')->toJson();
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

66
        $swagger = /** @scrutinizer ignore-call */ OpenApi\scan(APPLICATION_PATH.'/src')->toJson();
Loading history...
67
        $response = new Response();
68
        $response = $response->withHeader('Content-Type', 'application/json');
69
        $response->getBody()->write($swagger);
70
        return $response;
71
    }
72
73 1
    public function fakeClientCallbackAction()
74
    {
75 1
        $this->sendJsonResponse($this->getParams());
76 1
    }
77
78
    /**
79
     * temporary development view for writing email templates
80
     * @return Response
81
     */
82
    public function emailAction()
83
    {
84
        $reg = $this->getViewEngine()->render('emails/user_registration/user_registration', [
85
            'siteUrl' => $this->getServerEnvironment()->getSiteURL(),
86
            'activationLink' => '/user/activate/[email protected]/dhfdhfddhfdh',
87
        ]);
88
        $response = new Response();
89
        $response->getBody()->write($reg);
90
        return $response;
91
    }
92
}
93