Passed
Pull Request — master (#7)
by Luis
20:14 queued 05:16
created

VisibilityFilters   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 9 2
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 7.2
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Parser\Code\Builders\Members;
9
10
use PhpParser\Node\Stmt;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use PhpParser\Node\Stmt\ClassConst;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\ClassConst was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use PhpParser\Node\Stmt\ClassMethod;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\ClassMethod was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use PhpParser\Node\Stmt\Property;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\Property was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use PhUml\Parser\Code\Builders\Filters\VisibilityFilter;
15
16
/**
17
 * It can run one or more `VisibilityFilter`s.
18
 * Filters will exclude:
19
 *
20
 * - protected members
21
 * - private members
22
 * - both protected and private members if both filters are provided
23
 *
24
 * @see PrivateVisibilityFilter
25
 * @see ProtectedVisibilityFilter
26
 */
27
final class VisibilityFilters
28
{
29
    /** @var VisibilityFilter[] */
30
    protected $filters;
31
32
    /** @param VisibilityFilter[] $filters */
33
    public function __construct(array $filters = [])
34
    {
35
        $this->filters = $filters;
36
    }
37
38
    /**
39
     * @param Property[]|ClassMethod[]|ClassConst[] $classMembers
40
     * @return Property[]|ClassMethod[]|ClassConst[]
41
     */
42
    public function apply(array $classMembers): array
43
    {
44
        $attributes = $classMembers;
45
        foreach ($this->filters as $filter) {
46
            $attributes = array_filter($attributes, static function (Stmt $member) use ($filter): bool {
47
                return $filter->accept($member);
48
            });
49
        }
50
        return $attributes;
51
    }
52
}
53