AAdapter::getAuth()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_auth_sources\Access\SourcesAdapters;
4
5
6
use kalanis\kw_accounts\Interfaces;
7
use kalanis\kw_auth_sources\AuthSourcesException;
8
use kalanis\kw_auth_sources\Traits\TLang;
9
10
11
/**
12
 * Class AAdapter
13
 * @package kalanis\kw_auth_sources\Access\SourcesAdapters
14
 */
15
abstract class AAdapter
16
{
17
    use TLang;
18
19
    protected ?Interfaces\IAuth $auth = null;
20
    protected ?Interfaces\IProcessAccounts $accounts = null;
21
    protected ?Interfaces\IProcessClasses $classes = null;
22
    protected ?Interfaces\IProcessGroups $groups = null;
23
24
    /**
25
     * @throws AuthSourcesException
26
     * @return Interfaces\IAuth
27
     */
28 6
    public function getAuth(): Interfaces\IAuth
29
    {
30 6
        if (!$this->auth) {
31 1
            throw new AuthSourcesException($this->getAusLang()->kauGroupMissAccounts());
32
        }
33 5
        return $this->auth;
34
    }
35
36
    /**
37
     * @throws AuthSourcesException
38
     * @return Interfaces\IProcessAccounts
39
     */
40 6
    public function getAccounts(): Interfaces\IProcessAccounts
41
    {
42 6
        if (!$this->accounts) {
43 1
            throw new AuthSourcesException($this->getAusLang()->kauGroupMissAuth());
44
        }
45 5
        return $this->accounts;
46
    }
47
48
    /**
49
     * @throws AuthSourcesException
50
     * @return Interfaces\IProcessClasses
51
     */
52 5
    public function getClasses(): Interfaces\IProcessClasses
53
    {
54 5
        if (!$this->classes) {
55 1
            throw new AuthSourcesException($this->getAusLang()->kauGroupMissClasses());
56
        }
57 4
        return $this->classes;
58
    }
59
60
    /**
61
     * @throws AuthSourcesException
62
     * @return Interfaces\IProcessGroups
63
     */
64 5
    public function getGroups(): Interfaces\IProcessGroups
65
    {
66 5
        if (!$this->groups) {
67 1
            throw new AuthSourcesException($this->getAusLang()->kauGroupMissGroups());
68
        }
69 4
        return $this->groups;
70
    }
71
}
72