more refactoring; now the package hook starts to make sense
[pharext/pharext] / src / pharext / SourceDir / Pharext.php
diff --git a/src/pharext/SourceDir/Pharext.php b/src/pharext/SourceDir/Pharext.php
deleted file mode 100644 (file)
index 8ca0901..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-namespace pharext\SourceDir;
-
-use pharext\Command;
-use pharext\Exception;
-use pharext\SourceDir;
-
-/**
- * A source directory containing pharext_package.php and eventually pharext_install.php
- */
-class Pharext implements \IteratorAggregate, SourceDir
-{
-       /**
-        * @var pharext\Command
-        */
-       private $cmd;
-       
-       /**
-        * @var string
-        */
-       private $path;
-       
-       /**
-        * @var callable
-        */
-       private $iter;
-
-       /**
-        * @inheritdoc
-        * @see \pharext\SourceDir::__construct()
-        */
-               public function __construct(Command $cmd, $path) {
-               $this->cmd = $cmd;
-               $this->path = $path;
-               
-               $callable = include "$path/pharext_package.php";
-               if (!is_callable($callable)) {
-                       throw new Exception("Package hook did not return a callable");
-               }
-               $this->iter = $callable($cmd, $path);
-       }
-
-       /**
-        * @inheritdoc
-        * @see \pharext\SourceDir::getBaseDir()
-        */
-       public function getBaseDir() {
-               return $this->path;
-       }
-
-       /**
-        * Implements IteratorAggregate
-        * @see IteratorAggregate::getIterator()
-        */
-       public function getIterator() {
-               if (!is_callable($this->iter)) {
-                       return new Git($this->cmd, $this->path);
-               } 
-               return call_user_func($this->iter, $this->cmd, $this->path);
-       } 
-}