User::view()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace User\Controller;
5
6
use Silex\Application;
7
use Common\Response as View;
8
9
/**
10
 * User Controller
11
 *
12
 * @author Thiago Paes <[email protected]>
13
 */
14
final class User
15
{
16
    /**
17
     * Route to /user/
18
     *
19
     * @param  Application $app
20
     * @return View
21
     */
22
    public function get(Application $app): View
23
    {
24
        /* @var $users array */
25
        $users    = $app['user.service']->listAll();
26
27
        return new View($users, View::HTTP_OK);
28
    }
29
30
    /**
31
     * Retrieves information from user
32
     *
33
     * @param  Application $app
34
     * @return View
35
     */
36
    public function view(Application $app): View
37
    {
38
        /* @var $request \Symfony\Component\HttpFoundation\Request */
39
        $request = $app['request'];
40
41
        /* @var $id int */
42
        $id      = (int) $request->get('id');
43
44
        /* @var $user \User\Entity\UserInterface */
45
        $user    = $app['user.service']->findByUserId($id);
46
47
        return new View($user, View::HTTP_OK);
48
    }
49
}
50