User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 1
A view() 0 13 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