Passed
Push — master ( 25a010...d9c103 )
by
unknown
14:59
created

Demand::forUc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Beuser\Domain\Model;
19
20
/**
21
 * Demand filter for listings
22
 * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
23
 */
24
class Demand
25
{
26
    public const ALL = 0;
27
28
    public const USERTYPE_ADMINONLY = 1;
29
    public const USERTYPE_USERONLY = 2;
30
31
    public const STATUS_ACTIVE = 1;
32
    public const STATUS_INACTIVE = 2;
33
34
    public const LOGIN_SOME = 1;
35
    public const LOGIN_NONE = 2;
36
37
    protected string $userName = '';
38
    protected int $userType = self::ALL;
39
    protected int $status = self::ALL;
40
    protected int $logins = 0;
41
    protected int $backendUserGroup = 0;
42
43
    public static function fromUc(array $uc): self
44
    {
45
        $demand = new self();
46
        $demand->userName = (string)($uc['userName'] ?? '');
47
        $demand->userType = (int)($uc['userType'] ?? 0);
48
        $demand->status = (int)($uc['status'] ?? 0);
49
        $demand->logins = (int)($uc['logins'] ?? 0);
50
        $demand->backendUserGroup = (int)($uc['backendUserGroup'] ?? 0);
51
        return $demand;
52
    }
53
54
    public function forUc(): array
55
    {
56
        return [
57
            'userName' => $this->getUserName(),
58
            'userType' => $this->getUserType(),
59
            'status' => $this->getStatus(),
60
            'logins' => $this->getLogins(),
61
            'backendUserGroup' => $this->getBackendUserGroup(),
62
        ];
63
    }
64
65
    public function setUserName(string $userName): void
66
    {
67
        $this->userName = $userName;
68
    }
69
70
    public function getUserName(): string
71
    {
72
        return $this->userName;
73
    }
74
75
    public function setUserType(int $userType): void
76
    {
77
        $this->userType = $userType;
78
    }
79
80
    public function getUserType(): int
81
    {
82
        return $this->userType;
83
    }
84
85
    public function setStatus(int $status): void
86
    {
87
        $this->status = $status;
88
    }
89
90
    public function getStatus(): int
91
    {
92
        return $this->status;
93
    }
94
95
    public function setLogins(int $logins): void
96
    {
97
        $this->logins = $logins;
98
    }
99
100
    public function getLogins(): int
101
    {
102
        return $this->logins;
103
    }
104
105
    public function setBackendUserGroup(int $backendUserGroup): void
106
    {
107
        $this->backendUserGroup = $backendUserGroup;
108
    }
109
110
    public function getBackendUserGroup(): int
111
    {
112
        return $this->backendUserGroup;
113
    }
114
}
115