Completed
Branch v2.0.0 (e47d62)
by Alexander
03:40
created

UserClientService::deleteUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Domain\User;
4
5
use Core\Domain\DomainClientService;
6
use Domain\User\Exceptions\UserException;
7
use Domain\User\Factories\UserFactory;
8
use stdClass;
9
10
class UserClientService extends DomainClientService
11
{
12
    public function createUser(array $data = []): int
13
    {
14
        $db = $this->getDI()->get('db');
15
        $db->begin();
16
17
        try {
18
            $user = UserFactory::create($data);
19
            $repository = new UserRepository($this->getDI());
20
21
            $userID = $repository->insertUserIntoDb($user);
22
            $db->commit();
23
24
            $user->setUserId($userID);
25
26
            return $user->getUserID();
27
        } catch (UserException $e) {
28
            $db->rollback;
29
        }
30
    }
31
32
    public function retrieveUserObject(array $params = []): stdClass
33
    {
34
        $user = UserFactory::retrieve($params, $this->getDI());
35
36
        return $this->toJsonObject($user);
37
    }
38
39
    public function deleteUser(array $params = [])
40
    {
41
    }
42
43
    public function usersList(array $params = [])
44
    {
45
        // Build and return users list
46
    }
47
}
48