/
source.php
66 lines (52 loc) · 1.41 KB
/
source.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace mageekguy\atoum\iterators\recursives\atoum;
use
mageekguy\atoum,
mageekguy\atoum\iterators
;
class source implements \outerIterator
{
protected $pharDirectory = '';
protected $sourceDirectory = '';
protected $innerIterator = null;
public function __construct($sourceDirectory, $pharDirectory = null)
{
$this->sourceDirectory = (string) $sourceDirectory;
$this->pharDirectory = $pharDirectory === null ? null : (string) $pharDirectory;
$this->innerIterator = new \recursiveIteratorIterator(new iterators\filters\recursives\dot($this->sourceDirectory));
$this->innerIterator->rewind();
}
public function getSourceDirectory()
{
return $this->sourceDirectory;
}
public function getPharDirectory()
{
return $this->pharDirectory;
}
public function getInnerIterator()
{
return $this->innerIterator;
}
public function current()
{
$current = $this->innerIterator->current();
return $current === null ? null : (string) $current;
}
public function key()
{
return $this->pharDirectory === null ? $this->innerIterator->key() : preg_replace('#^(:[^:]+://)?' . preg_quote($this->sourceDirectory, '#') . '#', $this->pharDirectory, $this->innerIterator->current());
}
public function next()
{
return $this->innerIterator->next();
}
public function rewind()
{
return $this->innerIterator->rewind();
}
public function valid()
{
return $this->innerIterator->valid();
}
}