CompositeSources::readClasses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace kalanis\kw_auth_sources\Access;
4
5
6
use kalanis\kw_accounts\Interfaces;
7
8
9
/**
10
 * Class CompositeSources
11
 * @package kalanis\kw_auth_sources\Access
12
 */
13
class CompositeSources implements Interfaces\IAuthCert, Interfaces\IProcessAccounts, Interfaces\IProcessClasses, Interfaces\IProcessGroups
14
{
15
    protected SourcesAdapters\AAdapter $adapter;
16
17 26
    public function __construct(SourcesAdapters\AAdapter $adapter)
18
    {
19 26
        $this->adapter = $adapter;
20 26
    }
21
22 2
    public function getDataOnly(string $userName): ?Interfaces\IUser
23
    {
24 2
        return $this->adapter->getAuth()->getDataOnly($userName);
25
    }
26
27 2
    public function authenticate(string $userName, array $params = []): ?Interfaces\IUser
28
    {
29 2
        return $this->adapter->getAuth()->authenticate($userName, $params);
30
    }
31
32 2
    public function updateCertData(string $userName, ?string $certKey, ?string $certSalt): bool
33
    {
34 2
        $auth = $this->adapter->getAuth();
35 2
        if ($auth instanceof Interfaces\IAuthCert) {
36 1
            return $auth->updateCertData($userName, $certKey, $certSalt);
37
        }
38 1
        return false;
39
    }
40
41 2
    public function getCertData(string $userName): ?Interfaces\ICert
42
    {
43 2
        $auth = $this->adapter->getAuth();
44 2
        if ($auth instanceof Interfaces\IAuthCert) {
45 1
            return $auth->getCertData($userName);
46
        }
47 1
        return null;
48
    }
49
50 1
    public function createAccount(Interfaces\IUser $user, string $password): bool
51
    {
52 1
        return $this->adapter->getAccounts()->createAccount($user, $password);
53
    }
54
55 1
    public function readAccounts(): array
56
    {
57 1
        return $this->adapter->getAccounts()->readAccounts();
58
    }
59
60 1
    public function updateAccount(Interfaces\IUser $user): bool
61
    {
62 1
        return $this->adapter->getAccounts()->updateAccount($user);
63
    }
64
65 1
    public function updatePassword(string $userName, string $passWord): bool
66
    {
67 1
        return $this->adapter->getAccounts()->updatePassword($userName, $passWord);
68
    }
69
70 1
    public function deleteAccount(string $userName): bool
71
    {
72 1
        return $this->adapter->getAccounts()->deleteAccount($userName);
73
    }
74
75 1
    public function readClasses(): array
76
    {
77 1
        return $this->adapter->getClasses()->readClasses();
78
    }
79
80 1
    public function createGroup(Interfaces\IGroup $group): bool
81
    {
82 1
        return $this->adapter->getGroups()->createGroup($group);
83
    }
84
85 1
    public function getGroupDataOnly(string $groupId): ?Interfaces\IGroup
86
    {
87 1
        return $this->adapter->getGroups()->getGroupDataOnly($groupId);
88
    }
89
90 1
    public function readGroup(): array
91
    {
92 1
        return $this->adapter->getGroups()->readGroup();
93
    }
94
95 1
    public function updateGroup(Interfaces\IGroup $group): bool
96
    {
97 1
        return $this->adapter->getGroups()->updateGroup($group);
98
    }
99
100 1
    public function deleteGroup(string $groupId): bool
101
    {
102 1
        return $this->adapter->getGroups()->deleteGroup($groupId);
103
    }
104
105 2
    public function getAuth(): Interfaces\IAuth
106
    {
107 2
        return $this->adapter->getAuth();
108
    }
109
110 2
    public function getAccounts(): Interfaces\IProcessAccounts
111
    {
112 2
        return $this->adapter->getAccounts();
113
    }
114
115 1
    public function getClasses(): Interfaces\IProcessClasses
116
    {
117 1
        return $this->adapter->getClasses();
118
    }
119
120 1
    public function getGroups(): Interfaces\IProcessGroups
121
    {
122 1
        return $this->adapter->getGroups();
123
    }
124
}
125