protected function buildQuery()
{
if (!$this->dirs && !$this->files) {
throw new LogicException('You have not set any files or directory');
}
$command = '-n -q -b -X -charset UTF8';
if ($this->recursive) {
$command .= ' -r';
}
if (!empty($this->extensions)) {
if (!$this->extensionsToggle) {
$extensionPrefix = ' --ext';
} else {
$extensionPrefix = ' -ext';
}
foreach ($this->extensions as $extension) {
$command .= $extensionPrefix . ' ' . escapeshellarg($extension);
}
}
if (!$this->followSymLinks) {
$command .= ' -i SYMLINKS';
}
if ($this->ignoreDotFile) {
$command .= " -if '\$filename !~ /^\\./'";
}
foreach ($this->sort as $sort) {
$command .= ' -fileOrder ' . $sort;
}
foreach ($this->computeExcludeDirs($this->excludeDirs, $this->dirs) as $excludedDir) {
$command .= ' -i ' . escapeshellarg($excludedDir);
}
foreach ($this->dirs as $dir) {
$command .= ' ' . escapeshellarg(realpath($dir));
}
foreach ($this->files as $file) {
$command .= ' ' . escapeshellarg(realpath($file));
}
return $command;
}