3 namespace pharext\SourceDir
;
9 use FilesystemIterator
;
10 use IteratorAggregate
;
11 use RecursiveCallbackFilterIterator
;
12 use RecursiveDirectoryIterator
;
13 use RecursiveIteratorIterator
;
16 class Basic
implements IteratorAggregate
, SourceDir
22 public function __construct($path) {
26 public function getBaseDir() {
30 public function getPackageInfo() {
34 public function getLicense() {
35 if (($file = $this->findLicense($this->getBaseDir()))) {
36 return $this->readLicense($file);
41 public function getArgs() {
45 public function setArgs(Args
$args) {
48 public function filter($current, $key, $iterator) {
49 $sub = $current->getSubPath();
50 if ($sub === ".git" ||
$sub === ".hg" ||
$sub === ".svn") {
56 public function getIterator() {
57 $rdi = new RecursiveDirectoryIterator($this->path
,
58 FilesystemIterator
::CURRENT_AS_SELF |
// needed for 5.5
59 FilesystemIterator
::KEY_AS_PATHNAME |
60 FilesystemIterator
::SKIP_DOTS
);
61 $rci = new RecursiveCallbackFilterIterator($rdi, [$this, "filter"]);
62 $rii = new RecursiveIteratorIterator($rci);
63 foreach ($rii as $path => $child) {
64 if (!$child->isDir()) {
65 yield
realpath($path);