Passed
Push — master ( d309df...7ec489 )
by Petr
02:37
created

AGroups   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 42
ccs 8
cts 8
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A saveGroups() 0 3 1
A openGroups() 0 3 1
A __construct() 0 5 1
A checkRest() 0 2 1
1
<?php
2
3
namespace kalanis\kw_auth\Sources\Files;
4
5
6
use kalanis\kw_auth\AuthException;
7
use kalanis\kw_auth\Interfaces\IAccessGroups;
8
use kalanis\kw_auth\Interfaces\IKATranslations;
9
use kalanis\kw_locks\Interfaces\ILock;
10
11
12
/**
13
 * Class AGroups
14
 * @package kalanis\kw_auth\Sources\Files
15
 * Authenticate via files - manage groups
16
 */
17
abstract class AGroups implements IAccessGroups
18
{
19
    use TGroups;
20
    use TLines;
21
    use TStore;
22
23
    /** @var string */
24
    protected $path = '';
25
26
    /**
27
     * @param ILock $lock
28
     * @param string $path full path to group file
29
     * @param IKATranslations|null $lang
30
     */
31 10
    public function __construct(ILock $lock, string $path, ?IKATranslations $lang = null)
32
    {
33 10
        $this->setLang($lang);
34 10
        $this->initAuthLock($lock);
35 10
        $this->path = $path;
36
    }
37
38
    protected function checkRest(/** @scrutinizer ignore-unused */ int $groupId): void
39
    {
40
        // nothing here
41
    }
42
43
    /**
44
     * @throws AuthException
45
     * @return array<int, array<int, string>>
46
     */
47 8
    protected function openGroups(): array
48
    {
49 8
        return $this->openFile($this->path);
50
    }
51
52
    /**
53
     * @param array<int, array<int, string|int>> $lines
54
     * @throws AuthException
55
     */
56 3
    protected function saveGroups(array $lines): void
57
    {
58 3
        $this->saveFile($this->path, $lines);
59
    }
60
}
61