openshift makefile
[mdref/mdref] / mdref / RefListing.php
index d7180906479721f4066d54a6083b769bbf47ee8a..3816be23d60beb0b8a8c6ab33993e7efc39d7831 100644 (file)
@@ -2,6 +2,9 @@
 
 namespace mdref;
 
+/**
+ * A list of markdown reference files
+ */
 class RefListing implements \Countable, \Iterator
 {
        /**
@@ -16,6 +19,7 @@ class RefListing implements \Countable, \Iterator
        
        /**
         * @param \mdref\Path $path
+        * @param array $files
         */
        function __construct(Path $path, array $files) {
                $this->path = $path;
@@ -25,51 +29,55 @@ class RefListing implements \Countable, \Iterator
        }
        
        /**
-        * Copy constructor
-        * @param mixed $filter callable array filter or fnmatch pattern
-        * @return \mdref\RefListing
+        * Implements \Countable
+        * @return int
         */
-       function __invoke($filter) {
-               die(__METHOD__);
-               $that = clone $this;
-               $that->entries =  array_filter($that->entries, is_callable($filter) 
-                               ? $filter 
-                               : function($fn) use ($filter) {
-                                       return fnmatch($filter, $fn);
-                               }
-               );
-               return $that;
-       }
-       
-       function __toString() {
-               return __METHOD__;
-               return $this->format(substr($this->path, strlen($this->path->getBaseDir())));
-       }
-       
        function count() {
                return count($this->entries);
        }
        
+       /**
+        * Implements \Iterator
+        */
        function rewind() {
                reset($this->entries);
        }
        
+       /**
+        * Implements \Iterator
+        * @return bool
+        */
        function valid() {
                return null !== key($this->entries);
        }
        
+       /**
+        * Implements \Iterator
+        * @return string
+        */
        function key() {
                return $this->path->getSubPath(current($this->entries));
        }
        
+       /**
+        * Implements \Iterator
+        */
        function next() {
                next($this->entries);
        }
-       
+
+       /**
+        * Implements \Iterator
+        * @return \mdref\RefEntry
+        */
        function current() {
                return new RefEntry($this->path, $this->key());//$this->format($this->key());
        }
        
+       /**
+        * Get the parent reference entry
+        * @return null|\mdref\RefEntry
+        */
        function getParent() {
                switch ($parent = dirname($this->path->getPathName())) {
                        case ".":
@@ -80,32 +88,11 @@ class RefListing implements \Countable, \Iterator
                }
        }
        
+       /**
+        * Get the reference entry this reflist is based of
+        * @return \mdref\RefEntry
+        */
        function getSelf() {
                return new RefEntry($this->path);
        }
-       
-       function format($entry) {
-               return __METHOD__;
-               $ns = "";
-               if (strlen($entry = trim($entry, DIRECTORY_SEPARATOR))) {
-                       $upper = ctype_upper($entry[0]);
-                       $parts = explode(DIRECTORY_SEPARATOR, $entry);
-                       
-                       for ($i = 0; $i < count($parts); ++$i) {
-                               if (!strlen($parts[$i]) || $parts[$i] === ".") {
-                                       continue;
-                               }
-                               if (strlen($ns)) {
-                                       if ($upper && !ctype_upper($parts[$i][0])) {
-                                               $ns .= "::";
-                                       } else {
-                                               $ns .= "\\";
-                                       }
-                               }
-                               $ns .= $parts[$i];
-                               $upper = ctype_upper($parts[$i][0]);
-                       }
-               }
-               return $ns;
-       }
-}
\ No newline at end of file
+}