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

Entry::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 19
rs 9.4285
cc 1
eloc 17
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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