basic source dirs && general tarball fixup
[pharext/pharext] / src / pharext / SourceDir / Basic.php
diff --git a/src/pharext/SourceDir/Basic.php b/src/pharext/SourceDir/Basic.php
new file mode 100644 (file)
index 0000000..5d44941
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace pharext\SourceDir;
+
+use pharext\Cli\Args;
+use pharext\SourceDir;
+
+use FilesystemIterator;
+use IteratorAggregate;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+
+
+class Basic implements IteratorAggregate, SourceDir
+{
+       private $path;
+       
+       public function __construct($path) {
+               $this->path = $path;
+       }
+       
+       public function getBaseDir() {
+               return $this->path;
+       }
+       
+       public function getPackageInfo() {
+               return [];
+       }
+       
+       public function getArgs() {
+               return [];
+       }
+       
+       public function setArgs(Args $args) {
+       }
+       
+       public function getIterator() {
+               $rdi = new RecursiveDirectoryIterator($this->path,
+                               FilesystemIterator::CURRENT_AS_SELF | // needed for 5.5
+                               FilesystemIterator::KEY_AS_PATHNAME |
+                               FilesystemIterator::SKIP_DOTS);
+               $rii = new RecursiveIteratorIterator($rdi,
+                               RecursiveIteratorIterator::CHILD_FIRST);
+               return $rii;
+               foreach ($rii as $path => $child) {
+                       if (!$child->isDir()) {
+                               #yield $path;
+                       }
+               }
+       }
+}