Completed
Push — develop ( 141adb...8f70d4 )
by Jaap
05:39
created

StripIgnore::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Descriptor\Filter;
17
18
use phpDocumentor\Descriptor\DescriptorAbstract;
19
use phpDocumentor\Descriptor\ProjectDescriptorBuilder;
20
use Webmozart\Assert\Assert;
21
22
/**
23
 * Strips any Descriptor if the ignore tag is present with that element.
24
 */
25
class StripIgnore implements FilterInterface
26
{
27
    /** @var ProjectDescriptorBuilder $builder */
28
    protected $builder;
29
30
    /**
31
     * Initializes this filter with an instance of the builder to retrieve the latest ProjectDescriptor from.
32
     */
33 1
    public function __construct(ProjectDescriptorBuilder $builder)
34
    {
35 1
        $this->builder = $builder;
36 1
    }
37
38
    /**
39
     * Filter Descriptor with ignore tags.
40
     */
41 3
    public function __invoke(?Filterable $value) : ?Filterable
42
    {
43 3
        Assert::nullOrIsInstanceOf($value, DescriptorAbstract::class);
44 3
        if ($value !== null && $value->getTags()->get('ignore')) {
45 1
            return null;
46
        }
47
48 2
        return $value;
49
    }
50
}
51