NamespaceFilter.php 1.33 KB
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * This file is part of "irstea/plantuml-bundle".
 *
 * Copyright (C) 2016-2019 IRSTEA
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License and the GNU
 * Lesser General Public License along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
19 20 21 22 23 24 25
 */

namespace Irstea\PlantUmlBundle\Model\Filter;

use ReflectionClass;

/**
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
26
 * Description of DirectoryFilter.
27
 */
28
class NamespaceFilter extends AbstractListFilter
29
{
30
    public const CONF_TYPE = 'namespaces';
31

32 33 34 35
    protected function extract(ReflectionClass $class)
    {
        return $class->getNamespaceName();
    }
36

37
    protected function matches($tested, $reference)
38
    {
39
        return strpos($tested, $reference) === 0;
40 41
    }

42
    protected function normalize($namespace)
43
    {
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
44
        return trim($namespace, '\\') . '\\';
45 46
    }
}