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

ClassFactory::attachTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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 League\Pipeline\Pipeline;
19
use League\Pipeline\PipelineInterface;
20
use Zend\Filter\FilterChain;
21
22
/**
23
 * Retrieves a series of filters to manipulate a specific Descriptor with during building.
24
 */
25
class ClassFactory
26
{
27
    /** @var array<string, Pipeline> */
28
    protected $chains = [];
29
30
    /**
31
     * Retrieves the filters for a class with a given FQCN.
32
     */
33 1
    public function getChainFor(string $fqcn) : Pipeline
34
    {
35 1
        if (!isset($this->chains[$fqcn])) {
36 1
            $this->chains[$fqcn] = new Pipeline();
37
        }
38
39 1
        return $this->chains[$fqcn];
40
    }
41
42
    public function attachTo(string $fqcn, FilterInterface $filter) : void
43
    {
44
        $chain = $this->getChainFor($fqcn);
45
        $this->chains[$fqcn] = $chain->pipe($filter);
46
    }
47
}
48