Passed
Branch master (c62005)
by ABDULMALIK
02:15
created

RbacManagerOptions::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Potievdev\SlimRbac\Structure;
4
5
use Doctrine\ORM\EntityManager;
6
7
/**
8
 * RBAC manager options structure.
9
 * The instance of this class accepted as argument for constructor of RbacManager.
10
 * Class RbacManagerOptions
11
 * @package Potievdev\Structure
12
 */
13
class RbacManagerOptions
14
{
15
    /** Default user id field name */
16
    const DEFAULT_USER_ID_FIELD_NAME = 'userId';
17
18
    const ATTRIBUTE_STORAGE_TYPE = 1;
19
    const HEADER_STORAGE_TYPE = 2;
20
    const COOKIE_STORAGE_TYPE = 3;
21
22
    /** @var  EntityManager */
23
    private $entityManager;
24
25
    /** @var string $userIdFieldName field name which saves user identifier in requests */
26
    private $userIdFieldName = self::DEFAULT_USER_ID_FIELD_NAME;
27
28
    /** @var int $userIdStorageType Type of storage where will be saved user id field */
29
    private $userIdStorageType = self::ATTRIBUTE_STORAGE_TYPE;
30
31
    public function __construct(EntityManager $entityManager)
32
    {
33
        $this->entityManager = $entityManager;
34
    }
35
36
    public function getEntityManager(): EntityManager
37
    {
38
        return $this->entityManager;
39
    }
40
41
    public function getUserIdFieldName(): string
42
    {
43
        return $this->userIdFieldName;
44
    }
45
46
    public function setUserIdFieldName(string $userIdFieldName): void
47
    {
48
        $this->userIdFieldName = $userIdFieldName;
49
    }
50
51
    public function getUserIdStorageType(): int
52
    {
53
        return $this->userIdStorageType;
54
    }
55
56
    public function setUserIdStorageType(int $userIdStorageType): void
57
    {
58
        $this->userIdStorageType = $userIdStorageType;
59
    }
60
61
}
62