Passed
Push — master ( b28c40...f61e74 )
by Petr
08:06
created

GroupsRecord   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
dl 0
loc 46
ccs 0
cts 38
cp 0
rs 10
c 1
b 0
f 1
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getGroupStatus() 0 3 1
A getGroupDesc() 0 3 1
A getGroupName() 0 3 1
A addEntries() 0 12 1
A getGroupAuthorId() 0 3 1
A getGroupId() 0 3 1
A getGroupParents() 0 5 1
1
<?php
2
3
namespace kalanis\kw_auth\Sources\Mapper\Database;
4
5
6
use kalanis\kw_auth\Interfaces\IGroup;
7
use kalanis\kw_mapper\Interfaces\IEntryType;
8
use kalanis\kw_mapper\Records\ASimpleRecord;
9
10
11
/**
12
 * Class GroupsRecord
13
 * @package kalanis\kw_auth\Sources\Mapper\Database
14
 * @property int $id
15
 * @property string $name
16
 * @property string $desc
17
 * @property int $status
18
 * @property int $authorId
19
 * @property int $parentId
20
 * @property UsersRecord[] $authors
21
 * @property UsersRecord[] $members
22
 * @property GroupsRecord[] $parents
23
 * @codeCoverageIgnore remote source
24
 */
25
class GroupsRecord extends ASimpleRecord implements IGroup
26
{
27
    public function addEntries(): void
28
    {
29
        $this->addEntry('id', IEntryType::TYPE_INTEGER, 2048);
30
        $this->addEntry('name', IEntryType::TYPE_STRING, 512);
31
        $this->addEntry('desc', IEntryType::TYPE_STRING, 512);
32
        $this->addEntry('authorId', IEntryType::TYPE_INTEGER, 128);
33
        $this->addEntry('parentId', IEntryType::TYPE_INTEGER, 2048);
34
        $this->addEntry('status', IEntryType::TYPE_INTEGER, 4);
35
        $this->addEntry('authors', IEntryType::TYPE_ARRAY, []);
36
        $this->addEntry('members', IEntryType::TYPE_ARRAY, []);
37
        $this->addEntry('parents', IEntryType::TYPE_ARRAY, []);
38
        $this->setMapper(GroupsMapper::class);
39
    }
40
41
    public function getGroupId(): int
42
    {
43
        return intval($this->id);
44
    }
45
46
    public function getGroupName(): string
47
    {
48
        return strval($this->name);
49
    }
50
51
    public function getGroupDesc(): string
52
    {
53
        return strval($this->desc);
54
    }
55
56
    public function getGroupAuthorId(): int
57
    {
58
        return intval($this->authorId);
59
    }
60
61
    public function getGroupStatus(): int
62
    {
63
        return intval($this->status);
64
    }
65
66
    public function getGroupParents(): array
67
    {
68
        return array_map(function (GroupsRecord $record) {
69
            return intval($record->id);
70
        }, $this->parents);
71
    }
72
}
73