GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Board   A
last analyzed

Complexity

Total Complexity 34

Size/Duplication

Total Lines 349
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2
Metric Value
wmc 34
lcom 3
cbo 2
dl 0
loc 349
rs 9.2

25 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __toString() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A setName() 0 6 1
A getDescription() 0 4 1
A setDescription() 0 6 1
A getListOrderPriority() 0 4 1
A setListOrderPriority() 0 6 1
A getCachedTopicCount() 0 4 1
A setCachedTopicCount() 0 6 1
A getCachedPostCount() 0 4 1
A setCachedPostCount() 0 6 1
A getReadAuthorisedRoles() 0 4 1
A setReadAuthorisedRoles() 0 6 1
A hasReadAuthorisedRole() 0 4 1
A isAuthorisedToRead() 0 14 4
A getTopicCreateAuthorisedRoles() 0 4 1
A setTopicCreateAuthorisedRoles() 0 6 1
A hasTopicCreateAuthorisedRole() 0 4 1
A isAuthorisedToCreateTopic() 0 14 4
A getTopicReplyAuthorisedRoles() 0 4 1
A setTopicReplyAuthorisedRoles() 0 6 1
A hasTopicReplyAuthorisedRole() 0 4 1
A isAuthorisedToReplyToTopic() 0 14 4
1
<?php
2
3
/*
4
 * This file is part of the CCDNForum ForumBundle
5
 *
6
 * (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/>
7
 *
8
 * Available on github <http://www.github.com/codeconsortium/>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace CCDNForum\ForumBundle\Entity;
15
16
use CCDNForum\ForumBundle\Entity\Model\Board as AbstractBoard;
17
use Symfony\Component\Security\Core\SecurityContextInterface;
18
19
/**
20
 *
21
 * @category CCDNForum
22
 * @package  ForumBundle
23
 *
24
 * @author   Reece Fowell <[email protected]>
25
 * @license  http://opensource.org/licenses/MIT MIT
26
 * @version  Release: 2.0
27
 * @link     https://github.com/codeconsortium/CCDNForumForumBundle
28
 *
29
 */
30
class Board extends AbstractBoard
31
{
32
    /**
33
     *
34
     * @var integer $id
35
     */
36
    protected $id;
37
38
    /**
39
     *
40
     * @var string name
41
     */
42
    protected $name;
43
44
    /**
45
     *
46
     * @var string $description\
47
     */
48
    protected $description;
49
50
    /**
51
     *
52
     * @var integer $cachedTopicCount
53
     */
54
    protected $cachedTopicCount = 0;
55
56
    /**
57
     *
58
     * @var integer $cachedPostCount
59
     */
60
    protected $cachedPostCount = 0;
61
62
    /**
63
     *
64
     * @var integer $listOrderPriority
65
     */
66
    protected $listOrderPriority = 0;
67
68
    /**
69
     *
70
     * @var array $readAuthorisedRoles
71
     */
72
    protected $readAuthorisedRoles;
73
74
    /**
75
     *
76
     * @var array $topicCreateAuthorisedRoles
77
     */
78
    protected $topicCreateAuthorisedRoles;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $topicCreateAuthorisedRoles exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
79
80
    /**
81
     *
82
     * @var array $topicReplyAuthorisedRoles
83
     */
84
    protected $topicReplyAuthorisedRoles;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $topicReplyAuthorisedRoles exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
85
86
    /**
87
     *
88
     * @access public
89
     */
90
    public function __construct()
91
    {
92
        parent::__construct();
93
94
        // your own logic
95
        $this->readAuthorisedRoles = array();
96
        $this->topicCreateAuthorisedRoles = array();
97
        $this->topicReplyAuthorisedRoles = array();
98
    }
99
100
    public function __toString()
101
    {
102
        return $this->name;
103
    }
104
105
    /**
106
     * Get id
107
     *
108
     * @return integer
109
     */
110
    public function getId()
111
    {
112
        return $this->id;
113
    }
114
115
    /**
116
     * Get name
117
     *
118
     * @return string
119
     */
120
    public function getName()
121
    {
122
        return $this->name;
123
    }
124
125
    /**
126
     * Set name
127
     *
128
     * @param  string $name
129
     * @return Board
130
     */
131
    public function setName($name)
132
    {
133
        $this->name = $name;
134
135
        return $this;
136
    }
137
138
    /**
139
     * Get description
140
     *
141
     * @return string
142
     */
143
    public function getDescription()
144
    {
145
        return $this->description;
146
    }
147
148
    /**
149
     * Set description
150
     *
151
     * @param  string $description
152
     * @return Board
153
     */
154
    public function setDescription($description)
155
    {
156
        $this->description = $description;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get list_order_priority
163
     *
164
     * @return integer
165
     */
166
    public function getListOrderPriority()
167
    {
168
        return $this->listOrderPriority;
169
    }
170
171
    /**
172
     * Set list_order_priority
173
     *
174
     * @param  integer $listOrderPriority
175
     * @return Board
176
     */
177
    public function setListOrderPriority($listOrderPriority)
178
    {
179
        $this->listOrderPriority = $listOrderPriority;
180
181
        return $this;
182
    }
183
184
    /**
185
     * Get cachedTopicCount
186
     *
187
     * @return integer
188
     */
189
    public function getCachedTopicCount()
190
    {
191
        return $this->cachedTopicCount;
192
    }
193
194
    /**
195
     * Set cachedTopicCount
196
     *
197
     * @param  integer $cachedTopicCount
198
     * @return Board
199
     */
200
    public function setCachedTopicCount($cachedTopicCount)
201
    {
202
        $this->cachedTopicCount = $cachedTopicCount;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get cachedPostCount
209
     *
210
     * @return integer
211
     */
212
    public function getCachedPostCount()
213
    {
214
        return $this->cachedPostCount;
215
    }
216
217
    /**
218
     * Set cachedPostCount
219
     *
220
     * @param  integer $cachedPostCount
221
     * @return Board
222
     */
223
    public function setCachedPostCount($cachedPostCount)
224
    {
225
        $this->cachedPostCount = $cachedPostCount;
226
227
        return $this;
228
    }
229
230
    /**
231
     * @return array
232
     */
233
    public function getReadAuthorisedRoles()
234
    {
235
        return $this->readAuthorisedRoles;
236
    }
237
238
    /**
239
     * @param  array $roles
0 ignored issues
show
Documentation introduced by
Should the type for parameter $roles not be null|array? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
240
     * @return Board
241
     */
242
    public function setReadAuthorisedRoles(array $roles = null)
243
    {
244
        $this->readAuthorisedRoles = $roles;
0 ignored issues
show
Documentation Bug introduced by
It seems like $roles can be null. However, the property $readAuthorisedRoles is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
245
246
        return $this;
247
    }
248
249
    /**
250
     * @param $role
251
     *
252
     * @return bool
253
     */
254
    public function hasReadAuthorisedRole($role)
255
    {
256
        return in_array($role, $this->readAuthorisedRoles);
257
    }
258
259
    /**
260
     * @param SecurityContextInterface $securityContext
261
     *
262
     * @return bool
263
     */
264
    public function isAuthorisedToRead(SecurityContextInterface $securityContext)
265
    {
266
        if (0 == count($this->readAuthorisedRoles)) {
267
            return true;
268
        }
269
270
        foreach ($this->readAuthorisedRoles as $role) {
271
            if ($securityContext->isGranted($role)) {
272
                return true;
273
            }
274
        }
275
276
        return false;
277
    }
278
279
    /**
280
     * @return array
281
     */
282
    public function getTopicCreateAuthorisedRoles()
283
    {
284
        return $this->topicCreateAuthorisedRoles;
285
    }
286
287
    /**
288
     * @param array $roles
0 ignored issues
show
Documentation introduced by
Should the type for parameter $roles not be null|array? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
289
     *
290
     * @return Board
291
     */
292
    public function setTopicCreateAuthorisedRoles(array $roles = null)
293
    {
294
        $this->topicCreateAuthorisedRoles = $roles;
0 ignored issues
show
Documentation Bug introduced by
It seems like $roles can be null. However, the property $topicCreateAuthorisedRoles is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
295
296
        return $this;
297
    }
298
299
    /**
300
     * @param $role
301
     *
302
     * @return bool
303
     */
304
    public function hasTopicCreateAuthorisedRole($role)
305
    {
306
        return in_array($role, $this->topicCreateAuthorisedRoles);
307
    }
308
309
    /**
310
     * @param SecurityContextInterface $securityContext
311
     *
312
     * @return bool
313
     */
314
    public function isAuthorisedToCreateTopic(SecurityContextInterface $securityContext)
315
    {
316
        if (0 == count($this->topicCreateAuthorisedRoles)) {
317
            return true;
318
        }
319
320
        foreach ($this->topicCreateAuthorisedRoles as $role) {
321
            if ($securityContext->isGranted($role)) {
322
                return true;
323
            }
324
        }
325
326
        return false;
327
    }
328
329
    /**
330
     * @return array
331
     */
332
    public function getTopicReplyAuthorisedRoles()
333
    {
334
        return $this->topicReplyAuthorisedRoles;
335
    }
336
337
    /**
338
     * @param array $roles
0 ignored issues
show
Documentation introduced by
Should the type for parameter $roles not be null|array? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
339
     *
340
     * @return Board
341
     */
342
    public function setTopicReplyAuthorisedRoles(array $roles = null)
343
    {
344
        $this->topicReplyAuthorisedRoles = $roles;
0 ignored issues
show
Documentation Bug introduced by
It seems like $roles can be null. However, the property $topicReplyAuthorisedRoles is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
345
346
        return $this;
347
    }
348
349
    /**
350
     * @param $role
351
     *
352
     * @return bool
353
     */
354
    public function hasTopicReplyAuthorisedRole($role)
355
    {
356
        return in_array($role, $this->topicReplyAuthorisedRoles);
357
    }
358
359
    /**
360
     * @param SecurityContextInterface $securityContext
361
     *
362
     * @return bool
363
     */
364
    public function isAuthorisedToReplyToTopic(SecurityContextInterface $securityContext)
365
    {
366
        if (0 == count($this->topicReplyAuthorisedRoles)) {
367
            return true;
368
        }
369
370
        foreach ($this->topicReplyAuthorisedRoles as $role) {
371
            if ($securityContext->isGranted($role)) {
372
                return true;
373
            }
374
        }
375
376
        return false;
377
    }
378
}
379