3 namespace pharext\Task
;
9 * Fixup package.xml files in an extracted PECL dir
11 class PeclFixup
implements Task
19 * @param string $source source directory
21 public function __construct($source) {
22 $this->source
= $source;
26 * @param bool $verbose
27 * @return string sanitized source location
28 * @throws \pahrext\Exception
30 public function run($verbose = false) {
31 $dirs = glob("{$this->source}/*", GLOB_ONLYDIR
);
32 $files = array_diff(glob("{$this->source}/*"), $dirs);
34 if (count($dirs) !== 1 ||
!count($files)) {
35 throw new Exception("Does not look like an extracted PECL dir: {$this->source}");
38 $dest = current($dirs);
40 foreach ($files as $file) {
41 if (!rename($file, "$dest/" . basename($file))) {