NamespaceFilter.php 635 Bytes
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
9
10
11
 */

namespace Irstea\PlantUmlBundle\Model\Filter;

use ReflectionClass;

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
12
 * Description of DirectoryFilter.
13
 */
14
class NamespaceFilter extends AbstractListFilter
15
{
16
    public const CONF_TYPE = 'namespaces';
17

18
19
20
21
    protected function extract(ReflectionClass $class)
    {
        return $class->getNamespaceName();
    }
22

23
    protected function matches($tested, $reference)
24
    {
25
        return strpos($tested, $reference) === 0;
26
27
    }

28
    protected function normalize($namespace)
29
    {
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
30
        return trim($namespace, '\\') . '\\';
31
32
    }
}