Failed Conditions
Push — master ( ec502b...7a4e00 )
by Florent
05:33
created

ApiController::scopeProtectionAction()   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
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\ServerBundle\Tests\TestBundle\Controller;
15
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
17
use OAuth2Framework\ServerBundle\Annotation\OAuth2;
18
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
19
use Symfony\Component\HttpFoundation\JsonResponse;
20
use Symfony\Component\HttpFoundation\Response;
21
22
/**
23
 * @Route("/api")
24
 */
25
class ApiController extends Controller
26
{
27
    /**
28
     * @param string $name
29
     *
30
     * @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...
31
     *
32
     * @Route("/hello/{name}", name="api_hello")
33
     */
34
    public function serviceAction(string $name)
35
    {
36
        return new JsonResponse(['name' => $name, 'message' => sprintf('Hello %s!', $name)]);
37
    }
38
39
    /**
40
     * @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...
41
     *
42
     * @OAuth2(scope="profile openid")
43
     * @Route("/hello-profile", name="api_scope")
44
     */
45
    public function scopeProtectionAction()
46
    {
47
        return new JsonResponse(['name' => 'I am protected by scope', 'message' => 'Hello!']);
48
    }
49
}
50