Test Failed
Pull Request — master (#1)
by
unknown
02:09
created

RequiredPermissions::isSeveralSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Maba\Bundle\RestBundle\Annotation;
5
6
use Maba\Bundle\RestBundle\Entity\RestRequestOptions;
7
use Maba\Bundle\RestBundle\Service\Annotation\ReflectionMethodWrapper;
8
9
/**
10
 * @Annotation
11
 * @Target({"CLASS", "METHOD"})
12
 */
13
class RequiredPermissions implements RestAnnotationInterface
14
{
15
    /**
16
     * @var array
17
     */
18
    private $permissions;
19
20
    public function __construct(array $options)
21
    {
22
        $this->setPermissions($options['permissions']);
23
    }
24
25
    /**
26
     * @param array $permissions
27
     * @return $this
28
     */
29
    private function setPermissions(array $permissions): self
30
    {
31
        $this->permissions = $permissions;
32
        return $this;
33
    }
34
35
    public function isSeveralSupported(): bool
36
    {
37
        return true;
38
    }
39
40
    public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod)
41
    {
42
        $options->setRequiredPermissions(
43
            array_unique(array_merge($options->getRequiredPermissions(), $this->permissions))
44
        );
45
    }
46
}
47