Failed Conditions
Push — master ( 349866...67c1d1 )
by Florent
10:56 queued 06:08
created

ApiController::serviceAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\SecurityBundle\Tests\TestBundle\Controller;
15
16
use OAuth2Framework\Component\Core\AccessToken\AccessToken;
17
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
18
use OAuth2Framework\SecurityBundle\Annotation\OAuth2;
19
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
20
use Symfony\Component\HttpFoundation\JsonResponse;
21
use Symfony\Component\HttpFoundation\Response;
22
23
/**
24
 * @Route("/api")
25
 */
26
class ApiController extends Controller
27
{
28
    /**
29
     * @param string $name
30
     *
31
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
32
     *
33
     * @Route("/hello/{name}", name="api_hello")
34
     */
35
    public function serviceAction(string $name)
36
    {
37
        return new JsonResponse(['name' => $name, 'message' => sprintf('Hello %s!', $name)]);
38
    }
39
40
    /**
41
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
42
     *
43
     * @OAuth2(scope="profile openid")
44
     * @Route("/hello-profile", name="api_scope")
45
     */
46
    public function scopeProtectionAction()
47
    {
48
        return new JsonResponse(['name' => 'I am protected by scope', 'message' => 'Hello!']);
49
    }
50
51
    /**
52
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
53
     *
54
     * @OAuth2(token_type="MAC")
55
     * @Route("/hello-token", name="api_token")
56
     */
57
    public function tokenTypeProtectionAction()
58
    {
59
        return new JsonResponse(['name' => 'I am protected by scope', 'message' => 'Hello!']);
60
    }
61
62
    /**
63
     * @Route("/hello-resolver", name="api_resolver")
64
     *
65
     * @param AccessToken $accessToken
66
     *
67
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
68
     */
69
    public function accessTokenResolverAction(AccessToken $accessToken)
70
    {
71
        return new JsonResponse($accessToken);
72
    }
73
}
74