sourcedir: guess basic package info
[pharext/pharext] / src / pharext / SourceDir / Basic.php
index 414c2015765a884f7c993316aca569f97645692c..13891d02a9b65eeb452a065e7453f4f9d6362086 100644 (file)
@@ -3,6 +3,8 @@
 namespace pharext\SourceDir;
 
 use pharext\Cli\Args;
+use pharext\License;
+use pharext\PackageInfo;
 use pharext\SourceDir;
 
 use FilesystemIterator;
@@ -14,6 +16,9 @@ use RecursiveIteratorIterator;
 
 class Basic implements IteratorAggregate, SourceDir
 {
+       use License;
+       use PackageInfo;
+       
        private $path;
        
        public function __construct($path) {
@@ -23,11 +28,22 @@ class Basic implements IteratorAggregate, SourceDir
        public function getBaseDir() {
                return $this->path;
        }
-       
+
+       /**
+        * @inheritdoc
+        * @return array
+        */
        public function getPackageInfo() {
-               return [];
+               return $this->findPackageInfo($this->getBaseDir());
        }
        
+       public function getLicense() {
+               if (($file = $this->findLicense($this->getBaseDir()))) {
+                       return $this->readLicense($file);
+               }
+               return "UNKNOWN";
+       }
+
        public function getArgs() {
                return [];
        }
@@ -52,7 +68,7 @@ class Basic implements IteratorAggregate, SourceDir
                $rii = new RecursiveIteratorIterator($rci);
                foreach ($rii as $path => $child) {
                        if (!$child->isDir()) {
-                               yield $path;
+                               yield realpath($path);
                        }
                }
        }