openssl signing
[pharext/pharext] / src / pharext / PharextSourceDir.php
1 <?php
2
3 namespace pharext;
4
5 class PharextSourceDir implements \IteratorAggregate, SourceDir
6 {
7 private $cmd;
8 private $path;
9 private $iter;
10
11 public function __construct(Command $cmd, $path) {
12 $this->cmd = $cmd;
13 $this->path = $path;
14
15 $callable = include "$path/pharext_package.php";
16 if (!is_callable($callable)) {
17 throw new \Exception("Package hook did not return a callable");
18 }
19 $this->iter = $callable($cmd, $path);
20 }
21
22 public function getBaseDir() {
23 return $this->path;
24 }
25
26 public function getIterator() {
27 if (!is_callable($this->iter)) {
28 throw new \Exception("Package hook callback did not return a callable");
29 }
30 return call_user_func($this->iter, $this->cmd, $this->path);
31 }
32 }