An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored8f94a20a
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace Irstea\PlantUmlBundle\Model\Filter;
use Irstea\PlantUmlBundle\Model\ClassFilterInterface;
use ReflectionClass;
/**
* Description of DirectoryFilter
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class ClassFilter implements ClassFilterInterface
{
/**
* @var string[]
*/
private $classes = [];
/**
* @var boolena
*/
private $notFound;
public function __construct(array $classes, $notFound = false)
{
$this->classes = array_map(
function ($class) {
return trim($class, '\\');
},
$classes
);
$this->notFound = $notFound;
}
public function accept(ReflectionClass $class)
{
$className = $class->getName();
if (in_array($className, $this->classes)) {
return !$this->notFound;
}
return $this->notFound;
}
public function describe()
{
return sprintf(
"Class is%s [%s]",
$this->notFound ? '' : ' not',
implode(', ', $this->classes)
);
}
}