Completed
Branch v2.0.0 (887ffb)
by Alexander
05:43
created

UsersController::retrieveById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Api\Controllers;
4
5
use Api\ApiController;
6
use Domain\User\UserClientService;
7
8
class UsersController extends ApiController
9
{
10
    public function create()
11
    {
12
        $data = $this->request->getJsonRawBody();
13
14
        $service = new UserClientService($this->getDi());
15
        $id = $service->createUser($data);
16
17
        $this->response->setStatusCode(201);
18
19
        return $this->json(['id' => $id]);
20
    }
21
22
    public function retrieveById($id)
23
    {
24
        $id = (int) $id;
25
        $service = new UserClientService($this->getDi());
26
        $user = $service->retrieveUserById($id);
27
28
        return $this->json(['user' => $user]);
29
    }
30
31
    public function usersList()
32
    {
33
        return $this->json([]);
34
    }
35
}
36