Completed
Pull Request — master (#30)
by
unknown
05:04
created

UserController::listAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace AppBundle\Controller\Api;
4
5
use AppBundle\Exception\JsonHttpException;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\Routing\Annotation\Route;
10
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
11
12
class UserController extends Controller
13
{
14
    /**
15
     * @Route("/users")
16
     *
17
     * @Method("GET")
18
     * @return JsonResponse
19
     */
20 View Code Duplication
    public function listAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $users = $this->getDoctrine()
23
            ->getRepository('AppBundle:User')
24
            ->findAll();
25
        if (!$users) {
26
            throw new JsonHttpException(404, 'User not found.');
27
        }
28
        return $this->json(['users' => $users], 200, [], [AbstractNormalizer::GROUPS => ['Short']]);
29
    }
30
}
31