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

FilterTrait   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 47
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getExcept() 0 3 1
A isSupportsMethod() 0 15 6
A getOnly() 0 3 1
A getNames() 0 3 1
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