6 * A list of markdown reference files
8 class RefListing
implements \Countable
, \Iterator
21 * @param \mdref\Path $path
24 function __construct(Path
$path, array $files) {
26 $this->entries
= array_map(function($fn) {
27 return substr(trim($fn, DIRECTORY_SEPARATOR
), 0, -3);
32 * Implements \Countable
36 return count($this->entries
);
40 * Implements \Iterator
43 reset($this->entries
);
47 * Implements \Iterator
51 return null !== key($this->entries
);
55 * Implements \Iterator
59 return $this->path
->getSubPath(current($this->entries
));
63 * Implements \Iterator
70 * Implements \Iterator
71 * @return \mdref\RefEntry
74 return new RefEntry($this->path
, $this->key());
78 * Get the parent reference entry
79 * @return null|\mdref\RefEntry
81 function getParent() {
82 switch ($parent = dirname($this->path
->getPathName())) {
87 return new RefEntry($this->path
, $parent);
92 * Get the reference entry this reflist is based of
93 * @return \mdref\RefEntry
96 return new RefEntry($this->path
);