8ca0901c24e696652e3ef0afa9f87b322e896f77
3 namespace pharext\SourceDir
;
10 * A source directory containing pharext_package.php and eventually pharext_install.php
12 class Pharext
implements \IteratorAggregate
, SourceDir
15 * @var pharext\Command
31 * @see \pharext\SourceDir::__construct()
33 public function __construct(Command
$cmd, $path) {
37 $callable = include "$path/pharext_package.php";
38 if (!is_callable($callable)) {
39 throw new Exception("Package hook did not return a callable");
41 $this->iter
= $callable($cmd, $path);
46 * @see \pharext\SourceDir::getBaseDir()
48 public function getBaseDir() {
53 * Implements IteratorAggregate
54 * @see IteratorAggregate::getIterator()
56 public function getIterator() {
57 if (!is_callable($this->iter
)) {
58 return new Git($this->cmd
, $this->path
);
60 return call_user_func($this->iter
, $this->cmd
, $this->path
);