Completed
Push — master ( e32eeb...714cda )
by
unknown
89:50 queued 46:29
created

Entry   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 195
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 15
lcom 0
cbo 0
dl 0
loc 195
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A getAcl() 0 4 1
A getMask() 0 4 1
A getId() 0 4 1
A getSecurityIdentity() 0 4 1
A getStrategy() 0 4 1
A isAuditFailure() 0 4 1
A isAuditSuccess() 0 4 1
A isGranting() 0 4 1
A setAuditFailure() 0 4 1
A setAuditSuccess() 0 4 1
A setMask() 0 4 1
A setStrategy() 0 4 1
A serialize() 0 13 1
A unserialize() 0 11 1
1
<?php
2
3
/*
4
 * This file is a copy of {@see Symfony\Component\Security\Acl\Domain\Entry}
5
 *
6
 * (c) Johannes M. Schmitt <[email protected]>
7
 */
8
9
namespace Oro\Bundle\SecurityBundle\Acl\Domain;
10
11
use Symfony\Component\Security\Acl\Model\AclInterface;
12
use Symfony\Component\Security\Acl\Model\AuditableEntryInterface;
13
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
14
15
/**
16
 * This class is mostly the copy of {@see Symfony\Component\Security\Acl\Domain\Entry} v2.7.3
17
 * but it has the fix on issue with unserialization https://bugs.php.net/bug.php?id=71940 that
18
 * present php versions from 7.0.0 to 7.0.5
19
 */
20
class Entry implements AuditableEntryInterface
21
{
22
    private $acl;
23
    private $mask;
24
    private $id;
25
    private $securityIdentity;
26
    private $strategy;
27
    private $auditFailure;
28
    private $auditSuccess;
29
    private $granting;
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param int                       $id
35
     * @param AclInterface              $acl
36
     * @param SecurityIdentityInterface $sid
37
     * @param string                    $strategy
38
     * @param int                       $mask
39
     * @param bool                      $granting
40
     * @param bool                      $auditFailure
41
     * @param bool                      $auditSuccess
42
     */
43
    public function __construct(
44
        $id,
45
        AclInterface $acl,
46
        SecurityIdentityInterface $sid,
47
        $strategy,
48
        $mask,
49
        $granting,
50
        $auditFailure,
51
        $auditSuccess
52
    ) {
53
        $this->id = $id;
54
        $this->acl = $acl;
55
        $this->securityIdentity = $sid;
56
        $this->strategy = $strategy;
57
        $this->mask = $mask;
58
        $this->granting = $granting;
59
        $this->auditFailure = $auditFailure;
60
        $this->auditSuccess = $auditSuccess;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getAcl()
67
    {
68
        return $this->acl;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function getMask()
75
    {
76
        return $this->mask;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getId()
83
    {
84
        return $this->id;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function getSecurityIdentity()
91
    {
92
        return $this->securityIdentity;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function getStrategy()
99
    {
100
        return $this->strategy;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function isAuditFailure()
107
    {
108
        return $this->auditFailure;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function isAuditSuccess()
115
    {
116
        return $this->auditSuccess;
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122
    public function isGranting()
123
    {
124
        return $this->granting;
125
    }
126
127
    /**
128
     * Turns on/off auditing on permissions denials.
129
     *
130
     * Do never call this method directly. Use the respective methods on the
131
     * AclInterface instead.
132
     *
133
     * @param bool $boolean
134
     */
135
    public function setAuditFailure($boolean)
136
    {
137
        $this->auditFailure = $boolean;
138
    }
139
140
    /**
141
     * Turns on/off auditing on permission grants.
142
     *
143
     * Do never call this method directly. Use the respective methods on the
144
     * AclInterface instead.
145
     *
146
     * @param bool $boolean
147
     */
148
    public function setAuditSuccess($boolean)
149
    {
150
        $this->auditSuccess = $boolean;
151
    }
152
153
    /**
154
     * Sets the permission mask.
155
     *
156
     * Do never call this method directly. Use the respective methods on the
157
     * AclInterface instead.
158
     *
159
     * @param int $mask
160
     */
161
    public function setMask($mask)
162
    {
163
        $this->mask = $mask;
164
    }
165
166
    /**
167
     * Sets the mask comparison strategy.
168
     *
169
     * Do never call this method directly. Use the respective methods on the
170
     * AclInterface instead.
171
     *
172
     * @param string $strategy
173
     */
174
    public function setStrategy($strategy)
175
    {
176
        $this->strategy = $strategy;
177
    }
178
179
    /**
180
     * Implementation of \Serializable.
181
     *
182
     * @return string
183
     */
184
    public function serialize()
185
    {
186
        $sid = clone $this->securityIdentity;
187
        return serialize(array(
188
            $this->mask,
189
            $this->id,
190
            $sid,
191
            $this->strategy,
192
            $this->auditFailure,
193
            $this->auditSuccess,
194
            $this->granting,
195
        ));
196
    }
197
198
    /**
199
     * Implementation of \Serializable.
200
     *
201
     * @param string $serialized
202
     */
203
    public function unserialize($serialized)
204
    {
205
        list($this->mask,
206
            $this->id,
207
            $this->securityIdentity,
208
            $this->strategy,
209
            $this->auditFailure,
210
            $this->auditSuccess,
211
            $this->granting
212
            ) = unserialize($serialized);
213
    }
214
}
215