public function trim()
{
$path = APP;
if (!empty($this->params['path']) && strpos($this->params['path'], '/') === 0) {
$path = $this->params['path'];
} elseif (!empty($this->params['path'])) {
$path .= $this->params['path'];
}
$folder = new Folder($path);
$r = $folder->findRecursive('.*\\.php');
$this->out("Checking *.php in " . $path);
foreach ($r as $file) {
$c = file_get_contents($file);
if (preg_match('/^[\\n\\r|\\n\\r|\\n|\\r|\\s]+\\<\\?php/', $c) || preg_match('/\\?\\>[\\n\\r|\\n\\r|\\n|\\r|\\s]+$/', $c)) {
$this->out('trimming' . $this->shortPath($file));
$c = preg_replace('/^[\\n\\r|\\n\\r|\\n|\\r|\\s]+\\<\\?php/', '<?php', $c);
$c = preg_replace('/\\?\\>[\\n\\r|\\n\\r|\\n|\\r|\\s]+$/', '?>', $c);
file_put_contents($file, $c);
}
}
}