NamespaceFilter.php 603 Bytes
Newer Older
1 2
<?php
/*
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 17
    const CONF_TYPE = 'namespaces';

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
    }
}