Completed
Push — master ( 127f02...ecc5eb )
by Lee
06:27 queued 02:34
created

ManagementApi::removeGroupingPolicies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
declare(strict_types=1);
4
5
namespace Casbin;
6
7
/**
8
 * Trait ManagementApi.
9
 *
10
 * @author [email protected]
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
11
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
12
trait ManagementApi
13
{
14
    /**
15
     * gets the list of subjects that show up in the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
16
     *
17
     * @return array
18
     */
19 6
    public function getAllSubjects(): array
20
    {
21 6
        return $this->model->getValuesForFieldInPolicyAllTypes('p', 0);
22
    }
23
24
    /**
25
     * gets the list of subjects that show up in the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
26
     *
27
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
28
     *
29
     * @return array
30
     */
31
    public function getAllNamedSubjects(string $ptype): array
32
    {
33
        return $this->model->getValuesForFieldInPolicy('p', $ptype, 0);
34
    }
35
36
    /**
37
     * gets the list of objects that show up in the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
38
     *
39
     * @return array
40
     */
41 3
    public function getAllObjects(): array
42
    {
43 3
        return $this->model->getValuesForFieldInPolicyAllTypes('p', 1);
44
    }
45
46
    /**
47
     * gets the list of objects that show up in the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
48
     *
49
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
50
     *
51
     * @return array
52
     */
53
    public function getAllNamedObjects(string $ptype): array
54
    {
55
        return $this->model->getValuesForFieldInPolicy('p', $ptype, 1);
56
    }
57
58
    /**
59
     * gets the list of actions that show up in the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
60
     *
61
     * @return array
62
     */
63 3
    public function getAllActions(): array
64
    {
65 3
        return $this->model->getValuesForFieldInPolicyAllTypes('p', 2);
66
    }
67
68
    /**
69
     * gets the list of actions that show up in the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
70
     *
71
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
72
     *
73
     * @return array
74
     */
75
    public function getAllNamedActions(string $ptype): array
76
    {
77
        return $this->model->getValuesForFieldInPolicy('p', $ptype, 2);
78
    }
79
80
    /**
81
     * gets the list of roles that show up in the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
82
     *
83
     * @return array
84
     */
85 6
    public function getAllRoles(): array
86
    {
87 6
        return $this->model->getValuesForFieldInPolicyAllTypes('g', 1);
88
    }
89
90
    /**
91
     * gets the list of roles that show up in the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
92
     *
93
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
94
     *
95
     * @return array
96
     */
97
    public function getAllNamedRoles(string $ptype): array
98
    {
99
        return $this->model->getValuesForFieldInPolicy('g', $ptype, 1);
100
    }
101
102
    /**
103
     * gets all the authorization rules in the policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
104
     *
105
     * @return array
106
     */
107 6
    public function getPolicy(): array
108
    {
109 6
        return $this->getNamedPolicy('p');
110
    }
111
112
    /**
113
     * gets all the authorization rules in the policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
114
     *
115
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
116
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
117
     *
118
     * @return array
119
     */
120 15
    public function getFilteredPolicy(int $fieldIndex, string ...$fieldValues): array
121
    {
122 15
        return $this->getFilteredNamedPolicy('p', $fieldIndex, ...$fieldValues);
123
    }
124
125
    /**
126
     * gets all the authorization rules in the named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
127
     *
128
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
129
     *
130
     * @return array
131
     */
132 6
    public function getNamedPolicy(string $ptype): array
133
    {
134 6
        return $this->model->getPolicy('p', $ptype);
135
    }
136
137
    /**
138
     * gets all the authorization rules in the named policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
139
     *
140
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
141
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
142
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
143
     *
144
     * @return array
145
     */
146 15
    public function getFilteredNamedPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): array
147
    {
148 15
        return $this->model->getFilteredPolicy('p', $ptype, $fieldIndex, ...$fieldValues);
149
    }
150
151
    /**
152
     * gets all the role inheritance rules in the policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
153
     *
154
     * @return array
155
     */
156 3
    public function getGroupingPolicy(): array
157
    {
158 3
        return $this->getNamedGroupingPolicy('g');
159
    }
160
161
    /**
162
     * gets all the role inheritance rules in the policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
163
     *
164
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
165
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
166
     *
167
     * @return array
168
     */
169 3
    public function getFilteredGroupingPolicy(int $fieldIndex, string ...$fieldValues): array
170
    {
171 3
        return $this->getFilteredNamedGroupingPolicy('g', $fieldIndex, ...$fieldValues);
172
    }
173
174
    /**
175
     * gets all the role inheritance rules in the policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
176
     *
177
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
178
     *
179
     * @return array
180
     */
181 3
    public function getNamedGroupingPolicy(string $ptype): array
182
    {
183 3
        return $this->model->getPolicy('g', $ptype);
184
    }
185
186
    /**
187
     * gets all the role inheritance rules in the policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
188
     *
189
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
190
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
191
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
192
     *
193
     * @return array
194
     */
195 3
    public function getFilteredNamedGroupingPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): array
196
    {
197 3
        return $this->model->getFilteredPolicy('g', $ptype, $fieldIndex, ...$fieldValues);
198
    }
199
200
    /**
201
     * determines whether an authorization rule exists.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
202
     *
203
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
204
     *
205
     * @return bool
206
     */
207 9
    public function hasPolicy(...$params): bool
208
    {
209 9
        return $this->hasNamedPolicy('p', ...$params);
210
    }
211
212
    /**
213
     * determines whether a named authorization rule exists.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
214
     *
215
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
216
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
217
     *
218
     * @return bool
219
     */
220 9
    public function hasNamedPolicy(string $ptype, ...$params): bool
221
    {
222 9
        if (1 == count($params) && is_array($params[0])) {
223 6
            $params = $params[0];
224
        }
225
226 9
        return $this->model->hasPolicy('p', $ptype, $params);
227
    }
228
229
    /**
230
     * AddPolicy adds an authorization rule to the current policy.
231
     * If the rule already exists, the function returns false and the rule will not be added.
232
     * Otherwise the function returns true by adding the new rule.
233
     *
234
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
235
     *
236
     * @return bool
237
     */
238 12
    public function addPolicy(...$params): bool
239
    {
240 12
        return $this->addNamedPolicy('p', ...$params);
241
    }
242
243
    /**
244
     * AddPolicies adds authorization rules to the current policy.
245
     * If the rule already exists, the function returns false for the corresponding rule and the rule will not be added.
246
     * Otherwise the function returns true for the corresponding rule by adding the new rule.
247
     *
248
     * @param array $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
249
     *
250
     * @return bool
251
     */
252 3
    public function addPolicies(array $rules): bool
253
    {
254 3
        return $this->addNamedPolicies('p', $rules);
255
    }
256
257
    /**
258
     * AddNamedPolicy adds an authorization rule to the current named policy.
259
     * If the rule already exists, the function returns false and the rule will not be added.
260
     * Otherwise the function returns true by adding the new rule.
261
     *
262
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
263
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
264
     *
265
     * @return bool
266
     */
267 12
    public function addNamedPolicy(string $ptype, ...$params): bool
268
    {
269 12
        if (1 == count($params) && is_array($params[0])) {
270 3
            $params = $params[0];
271
        }
272
273 12
        return $this->addPolicyInternal('p', $ptype, $params);
0 ignored issues
show
Bug introduced by
The method addPolicyInternal() does not exist on Casbin\ManagementApi. Did you maybe mean addPolicy()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

273
        return $this->/** @scrutinizer ignore-call */ addPolicyInternal('p', $ptype, $params);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
274
    }
275
276
    /**
277
     * AddNamedPolicies adds authorization rules to the current named policy.
278
     * If the rule already exists, the function returns false for the corresponding rule and the rule will not be added.
279
     * Otherwise the function returns true for the corresponding by adding the new rule.
280
     *
281
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
282
     * @param array  $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
283
     *
284
     * @return bool
285
     */
286 3
    public function addNamedPolicies(string $ptype, array $rules): bool
287
    {
288 3
        return $this->addPoliciesInternal('p', $ptype, $rules);
0 ignored issues
show
Bug introduced by
The method addPoliciesInternal() does not exist on Casbin\ManagementApi. Did you maybe mean addPolicies()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

288
        return $this->/** @scrutinizer ignore-call */ addPoliciesInternal('p', $ptype, $rules);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
289
    }
290
291
    /**
292
     * removes an authorization rule from the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
293
     *
294
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
295
     *
296
     * @return bool
297
     */
298 15
    public function removePolicy(...$params): bool
299
    {
300 15
        return $this->removeNamedPolicy('p', ...$params);
301
    }
302
303
    /**
304
     * removes an authorization rules from the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
305
     *
306
     * @param array $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
307
     *
308
     * @return bool
309
     */
310 3
    public function removePolicies(array $rules): bool
311
    {
312 3
        return $this->removeNamedPolicies('p', $rules);
313
    }
314
315
    /**
316
     * removes an authorization rule from the current policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
317
     *
318
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
319
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
320
     *
321
     * @return bool
322
     */
323 15
    public function removeFilteredPolicy(int $fieldIndex, string ...$fieldValues): bool
324
    {
325 15
        return $this->removeFilteredNamedPolicy('p', $fieldIndex, ...$fieldValues);
326
    }
327
328
    /**
329
     * removes an authorization rule from the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
330
     *
331
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
332
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
333
     *
334
     * @return bool
335
     */
336 15
    public function removeNamedPolicy(string $ptype, ...$params): bool
337
    {
338 15
        if (1 == count($params) && is_array($params[0])) {
339 3
            $params = $params[0];
340
        }
341
342 15
        return $this->removePolicyInternal('p', $ptype, $params);
0 ignored issues
show
Bug introduced by
The method removePolicyInternal() does not exist on Casbin\ManagementApi. Did you maybe mean removePolicy()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

342
        return $this->/** @scrutinizer ignore-call */ removePolicyInternal('p', $ptype, $params);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
343
    }
344
345
    /**
346
     * removes an authorization rules from the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
347
     *
348
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
349
     * @param array  $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
350
     *
351
     * @return bool
352
     */
353 3
    public function removeNamedPolicies(string $ptype, array $rules): bool
354
    {
355 3
        return $this->removePoliciesInternal('p', $ptype, $rules);
0 ignored issues
show
Bug introduced by
The method removePoliciesInternal() does not exist on Casbin\ManagementApi. Did you maybe mean removePolicies()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

355
        return $this->/** @scrutinizer ignore-call */ removePoliciesInternal('p', $ptype, $rules);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
356
    }
357
358
    /**
359
     * removes an authorization rule from the current named policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
360
     *
361
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
362
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
363
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
364
     *
365
     * @return bool
366
     */
367 15
    public function removeFilteredNamedPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): bool
368
    {
369 15
        return $this->removeFilteredPolicyInternal('p', $ptype, $fieldIndex, ...$fieldValues);
0 ignored issues
show
Bug introduced by
The method removeFilteredPolicyInternal() does not exist on Casbin\ManagementApi. Did you maybe mean removeFilteredPolicy()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

369
        return $this->/** @scrutinizer ignore-call */ removeFilteredPolicyInternal('p', $ptype, $fieldIndex, ...$fieldValues);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
370
    }
371
372
    /**
373
     * determines whether a role inheritance rule exists.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
374
     *
375
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
376
     *
377
     * @return bool
378
     */
379 3
    public function hasGroupingPolicy(...$params): bool
380
    {
381 3
        return $this->hasNamedGroupingPolicy('g', ...$params);
382
    }
383
384
    /**
385
     * determines whether a named role inheritance rule exists.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
386
     *
387
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
388
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
389
     *
390
     * @return bool
391
     */
392 3
    public function hasNamedGroupingPolicy(string $ptype, ...$params): bool
393
    {
394 3
        if (1 == count($params) && is_array($params[0])) {
395 3
            $params = $params[0];
396
        }
397
398 3
        return $this->model->hasPolicy('g', $ptype, $params);
399
    }
400
401
    /**
402
     * AddGroupingPolicy adds a role inheritance rule to the current policy.
403
     * If the rule already exists, the function returns false and the rule will not be added.
404
     * Otherwise the function returns true by adding the new rule.
405
     *
406
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
407
     *
408
     * @return bool
409
     */
410 15
    public function addGroupingPolicy(...$params): bool
411
    {
412 15
        return $this->addNamedGroupingPolicy('g', ...$params);
413
    }
414
415
    /**
416
     * AddGroupingPolicy adds a role inheritance rules to the current policy.
417
     * If the rule already exists, the function returns false and the rule will not be added.
418
     * Otherwise the function returns true by adding the new rule.
419
     *
420
     * @param array $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
421
     *
422
     * @return bool
423
     */
424 3
    public function addGroupingPolicies(array $rules): bool
425
    {
426 3
        return $this->addNamedGroupingPolicies('g', $rules);
427
    }
428
429
    /**
430
     * AddNamedGroupingPolicy adds a named role inheritance rule to the current policy.
431
     * If the rule already exists, the function returns false and the rule will not be added.
432
     * Otherwise the function returns true by adding the new rule.
433
     *
434
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
435
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
436
     *
437
     * @return bool
438
     */
439 15
    public function addNamedGroupingPolicy(string $ptype, ...$params): bool
440
    {
441 15
        if (1 == count($params) && is_array($params[0])) {
442 3
            $params = $params[0];
443
        }
444
445 15
        $ruleAdded = $this->addPolicyInternal('g', $ptype, $params);
446
447 15
        if ($this->autoBuildRoleLinks) {
448 15
            $this->buildRoleLinks();
0 ignored issues
show
Bug introduced by
It seems like buildRoleLinks() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

448
            $this->/** @scrutinizer ignore-call */ 
449
                   buildRoleLinks();
Loading history...
449
        }
450
451 15
        return $ruleAdded;
452
    }
453
454
    /**
455
     * AddNamedGroupingPolicy adds a named role inheritance rules to the current policy.
456
     * If the rule already exists, the function returns false and the rule will not be added.
457
     * Otherwise the function returns true by adding the new rule.
458
     *
459
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
460
     * @param array  $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
461
     *
462
     * @return bool
463
     */
464 3
    public function addNamedGroupingPolicies(string $ptype, array $rules): bool
465
    {
466 3
        $ruleAdded = $this->addPoliciesInternal('g', $ptype, $rules);
467
468 3
        if ($this->autoBuildRoleLinks) {
469 3
            $this->buildRoleLinks();
470
        }
471
472 3
        return $ruleAdded;
473
    }
474
475
    /**
476
     * removes a role inheritance rule from the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
477
     *
478
     * @param mixed ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
479
     *
480
     * @return bool
481
     */
482 12
    public function removeGroupingPolicy(...$params): bool
483
    {
484 12
        return $this->removeNamedGroupingPolicy('g', ...$params);
485
    }
486
487
    /**
488
     * removes a role inheritance rules from the current policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
489
     *
490
     * @param array $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
491
     *
492
     * @return bool
493
     */
494 3
    public function removeGroupingPolicies(array $rules): bool
495
    {
496 3
        return $this->removeNamedGroupingPolicies('g', $rules);
497
    }
498
499
    /**
500
     * removes a role inheritance rule from the current policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
501
     *
502
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
503
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
504
     *
505
     * @return bool
506
     */
507 12
    public function removeFilteredGroupingPolicy(int $fieldIndex, string ...$fieldValues): bool
508
    {
509 12
        return $this->removeFilteredNamedGroupingPolicy('g', $fieldIndex, ...$fieldValues);
510
    }
511
512
    /**
513
     * removes a role inheritance rule from the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
514
     *
515
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
516
     * @param mixed  ...$params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
517
     *
518
     * @return bool
519
     */
520 12
    public function removeNamedGroupingPolicy(string $ptype, ...$params): bool
521
    {
522 12
        if (1 == count($params) && is_array($params[0])) {
523 3
            $params = $params[0];
524
        }
525
526 12
        $ruleRemoved = $this->removePolicyInternal('g', $ptype, $params);
527
528 12
        if ($this->autoBuildRoleLinks) {
529 12
            $this->buildRoleLinks();
530
        }
531
532 12
        return $ruleRemoved;
533
    }
534
535
    /**
536
     * removes a role inheritance rules from the current named policy.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
537
     *
538
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
539
     * @param array  $rules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
540
     *
541
     * @return bool
542
     */
543 3
    public function removeNamedGroupingPolicies(string $ptype, array $rules): bool
544
    {
545 3
        $ruleRemoved = $this->removePoliciesInternal('g', $ptype, $rules);
546
547 3
        if ($this->autoBuildRoleLinks) {
548 3
            $this->buildRoleLinks();
549
        }
550
551 3
        return $ruleRemoved;
552
    }
553
554
    /**
555
     * removes a role inheritance rule from the current named policy, field filters can be specified.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
556
     *
557
     * @param string $ptype
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
558
     * @param int    $fieldIndex
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
559
     * @param string ...$fieldValues
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
560
     *
561
     * @return bool
562
     */
563 12
    public function removeFilteredNamedGroupingPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): bool
564
    {
565 12
        $ruleRemoved = $this->removeFilteredPolicyInternal('g', $ptype, $fieldIndex, ...$fieldValues);
566
567 12
        if ($this->autoBuildRoleLinks) {
568 12
            $this->buildRoleLinks();
569
        }
570
571 12
        return $ruleRemoved;
572
    }
573
574
    /**
575
     * adds a customized function.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
576
     *
577
     * @param string   $name
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
578
     * @param \Closure $func
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
579
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
580
    public function addFunction(string $name, \Closure $func): void
581
    {
582
        $this->fm->addFunction($name, $func);
583
    }
584
}
585