KwAuth   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 12 3
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