Passed
Push — master ( 141183...2b56eb )
by Petr
08:03
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 11
cts 11
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 17
    public function __construct(ILock $lock, string $path, ?IKATranslations $lang = null)
32
    {
33 17
        $this->setLang($lang);
34 17
        $this->initAuthLock($lock);
35 17
        $this->path = $path;
36 17
    }
37
38 5
    protected function checkRest(/** @scrutinizer ignore-unused */ int $groupId): void
39
    {
40
        // nothing here
41 5
    }
42
43
    /**
44
     * @throws AuthException
45
     * @return array<int, array<int, string>>
46
     */
47 13
    protected function openGroups(): array
48
    {
49 13
        return $this->openFile($this->path);
50
    }
51
52
    /**
53
     * @param array<int, array<int, string|int>> $lines
54
     * @throws AuthException
55
     */
56 5
    protected function saveGroups(array $lines): void
57
    {
58 5
        $this->saveFile($this->path, $lines);
59 3
    }
60
}
61