Completed
Push — master ( 166fce...64cbb1 )
by Indra
14s
created

FilterTrait::getExcept()   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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the MiddlewareBundle
7
 *
8
 * (c) Indra Gunawan <[email protected]>
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 Indragunawan\MiddlewareBundle\Annotation\Traits;
15
16
trait FilterTrait
17
{
18
    /**
19
     * @var string[]
20
     */
21
    protected $names;
22
23
    /**
24
     * @var string[]
25
     */
26
    protected $only;
27
28
    /**
29
     * @var string[]
30
     */
31
    protected $except;
32
33 5
    public function getNames(): array
34
    {
35 5
        return $this->names;
36
    }
37
38 5
    public function getOnly(): array
39
    {
40 5
        return $this->only;
41
    }
42
43 5
    public function getExcept(): array
44
    {
45 5
        return $this->except;
46
    }
47
48 1
    public function isSupportsMethod(string $method): bool
49
    {
50 1
        if (empty($this->only) && empty($this->except)) {
51 1
            return true;
52
        }
53
54 1
        if (\in_array($method, $this->only, true)) {
55 1
            return true;
56
        }
57
58 1
        if (!empty($this->except) && !\in_array($method, $this->except, true)) {
59 1
            return true;
60
        }
61
62 1
        return false;
63
    }
64
}
65