support for running .ext.phars without ext/phar
[pharext/pharext] / src / pharext / Task / Extract.php
index d68b426dd129a4ac5d6956f33cf4a9ecbd4281b2..3aa3f85950707841e0263d5a8ff441905fd91fad 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace pharext\Task;
 
+use pharext\Archive;
 use pharext\Task;
 use pharext\Tempdir;
 
@@ -22,7 +23,7 @@ class Extract implements Task
         * @param mixed $source archive location
         */
        public function __construct($source) {
-               if ($source instanceof Phar || $source instanceof PharData) {
+               if ($source instanceof Phar || $source instanceof PharData || $source instanceof Archive) {
                        $this->source = $source;
                } else {
                        $this->source = new PharData($source);
@@ -37,6 +38,9 @@ class Extract implements Task
                if ($verbose) {
                        printf("Extracting %s ...\n", basename($this->source->getPath()));
                }
+               if ($this->source instanceof Archive) {
+                       return $this->source->extract();
+               }
                $dest = new Tempdir("extract");
                $this->source->extractTo($dest);
                return $dest;