/**
* @param array $filters
* @return $this
*/
public function withFilters(array $filters)
{
if (!empty($filters)) {
foreach ($filters as $currentFilter) {
if (!strpos($currentFilter, ':')) {
throw new \InvalidArgumentException(sprintf('The filter "%s" is not a valid filter. A valid filter has the format <name>:<value>.', $currentFilter));
}
$currentFilterElements = explode(':', $currentFilter, 2);
switch (trim($currentFilterElements[0])) {
case 'exclude':
$this->finder->exclude($currentFilterElements[1]);
break;
case 'name':
$this->finder->name($currentFilterElements[1]);
break;
case 'notName':
$this->finder->notName($currentFilterElements[1]);
break;
case 'path':
$this->finder->path($currentFilterElements[1]);
break;
case 'size':
$this->finder->size($currentFilterElements[1]);
}
}
}
return $this;
}