Passed
Push — master ( d23f99...fe954a )
by Mike
02:29
created

UserFacade::getLoggedUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\User;
6
7
8
use DataProvider\UserAuthDataProvider;
9
use DataProvider\UserDataProvider;
10
use Xervice\Core\Facade\AbstractFacade;
11
12
/**
13
 * @method \Xervice\User\UserFactory getFactory()
14
 * @method \Xervice\User\UserConfig getConfig()
15
 * @method \Xervice\User\UserClient getClient()
16
 */
17
class UserFacade extends AbstractFacade
18
{
19
    /**
20
     * @param \DataProvider\UserAuthDataProvider $authDataProvider
21
     *
22
     * @return \DataProvider\UserDataProvider
23
     * @throws \Xervice\User\Business\Exception\UserException
24
     */
25
    public function login(UserAuthDataProvider $authDataProvider)
26
    {
27
        return $this->getFactory()->createLoginHandler()->login($authDataProvider);
28
    }
29
30
    public function logout(): void
31
    {
32
        $this->getFactory()->createLoginHandler()->logout();
33
    }
34
35
    /**
36
     * @return \DataProvider\UserDataProvider|null
37
     */
38
    public function getLoggedUser(): ?UserDataProvider
39
    {
40
        return $this->getFactory()->createLoginHandler()->getUser();
41
    }
42
43
    /**
44
     * @param \DataProvider\UserAuthDataProvider $authDataProvider
45
     *
46
     * @return bool
47
     * @throws \Xervice\User\Business\Exception\UserException
48
     */
49 1
    public function auth(UserAuthDataProvider $authDataProvider): bool
50
    {
51 1
        return $this->getFactory()->createAuthProvider()->auth($authDataProvider);
52
    }
53
54
    /**
55
     * @param \DataProvider\UserDataProvider $userDataProvider
56
     *
57
     * @return \DataProvider\UserDataProvider
58
     * @throws \Propel\Runtime\Exception\PropelException
59
     * @throws \Xervice\User\Business\Exception\UserException
60
     */
61 3
    public function createUser(UserDataProvider $userDataProvider): UserDataProvider
62
    {
63 3
        return $this->getFactory()->createUserWriter()->createUser($userDataProvider);
64
    }
65
66
    /**
67
     * @param \DataProvider\UserDataProvider $userDataProvider
68
     *
69
     * @return \DataProvider\UserDataProvider
70
     * @throws \Propel\Runtime\Exception\PropelException
71
     * @throws \Xervice\User\Business\Exception\UserException
72
     */
73 1
    public function updateUser(UserDataProvider $userDataProvider): UserDataProvider
74
    {
75 1
        return $this->getFactory()->createUserWriter()->updateUser($userDataProvider);
76
    }
77
78
    /**
79
     * @param int $userId
80
     *
81
     * @return \DataProvider\UserDataProvider
82
     */
83
    public function getUserFromId(int $userId): UserDataProvider
84
    {
85
        return $this->getFactory()->getQueryContainer()->getUserFromId($userId);
86
    }
87
88
    /**
89
     * @param string $email
90
     *
91
     * @return \DataProvider\UserDataProvider
92
     */
93 3
    public function getUserFromEmail(string $email): UserDataProvider
94
    {
95 3
        return $this->getFactory()->getQueryContainer()->getUserFromEmail($email);
96
    }
97
98
    /**
99
     * @param \DataProvider\UserDataProvider $userDataProvider
100
     *
101
     * @throws \Propel\Runtime\Exception\PropelException
102
     */
103 3
    public function deleteUser(UserDataProvider $userDataProvider): void
104
    {
105 3
        $this->getFactory()->createUserWriter()->deleteUser($userDataProvider);
106
    }
107
}