Failed Conditions
Push — master ( cccd95...989cb2 )
by Florent
03:57
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
c 0
b 0
f 0
rs 10
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\SecurityBundle\Tests\TestBundle\Controller;
15
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
17
use OAuth2Framework\SecurityBundle\Annotation\OAuth2;
18
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
19
use Symfony\Component\HttpFoundation\JsonResponse;
20
use Symfony\Component\HttpFoundation\Response;
21
22
/**
23
 * @OAuth2()
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("/scope", name="api_scope")
45
     */
46
    public function scopeProtectionAction()
47
    {
48
        return new JsonResponse(['name' => 'I am protected by scope', 'message' => 'Hello!']);
49
    }
50
}
51