* @throws \pahrext\Exception
*/
public function run($verbose = false) {
+ if ($verbose !== false) {
+ printf("Sanitizing PECL dir ...\n");
+ }
$dirs = glob("{$this->source}/*", GLOB_ONLYDIR);
$files = array_diff(glob("{$this->source}/*"), $dirs);
+ $check = array_reduce($files, function($r, $v) {
+ return $v && fnmatch("package*.xml", basename($v));
+ }, true);
- if (count($dirs) !== 1 || !count($files)) {
+ if (count($dirs) !== 1 || !$check) {
throw new Exception("Does not look like an extracted PECL dir: {$this->source}");
}
$dest = current($dirs);
foreach ($files as $file) {
+ if ($verbose) {
+ printf("Moving %s into %s ...\n", basename($file), basename($dest));
+ }
if (!rename($file, "$dest/" . basename($file))) {
throw new Exception;
}