KwAuth::__construct()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace kalanis\kw_auth_groups\Sources;
4
5
6
use kalanis\kw_accounts\AccountsException;
7
use kalanis\kw_accounts\Interfaces;
8
use kalanis\kw_groups\GroupsException;
9
use kalanis\kw_groups\Interfaces\ISource;
10
11
12
/**
13
 * Class KwAuth
14
 * @package kalanis\kw_auth_groups\Sources
15
 * Process the menu against the file tree
16
 * Load more already unloaded entries and remove non-existing ones
17
 */
18
class KwAuth implements ISource
19
{
20
    protected Interfaces\IProcessGroups $lib;
21
22 68
    public function __construct(Interfaces\IProcessGroups $lib)
23
    {
24 68
        $this->lib = $lib;
25 68
    }
26
27 22
    public function get(): array
28
    {
29
        try {
30 22
            $groups = $this->lib->readGroup();
31
            /** @var array<string, array<int, string>> $result */
32 21
            $result = [];
33 21
            foreach ($groups as $group) {
34 21
                $result[$group->getGroupId()] = $group->getGroupParents();
35
            }
36 21
            return $result;
37 1
        } catch (AccountsException $ex) {
38 1
            throw new GroupsException($ex->getMessage(), $ex->getCode(), $ex);
39
        }
40
    }
41
}
42