CodeDoc/Data/Param.php
authorAlan Knowles <alan@roojs.com>
Tue, 25 Oct 2016 07:04:07 +0000 (15:04 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 25 Oct 2016 07:04:07 +0000 (15:04 +0800)
CodeDoc/Data/Param.php [new file with mode: 0644]

diff --git a/CodeDoc/Data/Param.php b/CodeDoc/Data/Param.php
new file mode 100644 (file)
index 0000000..a2df732
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.txt.                                 |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Alan Knowles <alan@akbkhome.com>                      |
+// +----------------------------------------------------------------------+
+//
+
+/**
+*   Method and Class parameter data container
+*
+*   @package  PHP_CodeDoc
+*   @access   public
+*   @author   Alan Knowles <alan@akbkhome.com>
+*
+*/
+class PHP_CodeDoc_Data_Param {
+    var $name ='';        // name of parameter
+    var $Value = '';       // default value
+    var $desc = '';
+    var $type = '';
+    
+    
+    function descToHTML()
+    {
+        
+        $lines = explode("\n", $this->desc);
+        if (count($lines) < 2) {
+            return $this->desc;
+        }
+        if (preg_match('/array/i', $this->type) && preg_match('/\+\s+[a-z0-9_-]+:/', $this->desc)) {
+            // dl list...
+            
+            $ret = array_shift($lines) . "<br/><dl>";
+            $cur = false;
+            $sets = array();
+            foreach($lines as $l) {
+                $m = array();
+                if (preg_match('/^\s+\+\s+([a-z0-9_-]+):\s+(.*)$/i', $l, $m)) {
+                    if ($cur) {
+                        $sets[] = $cur;
+                    }
+                    $cur = array('key'=>$m[1], 'val' => $m[2] );
+                    continue;
+                }
+                if ($cur) {
+                    $cur['val'] .= "\n" . $l;
+                }
+                
+            }
+            if ($cur) {
+                $sets[] = $cur;
+            }
+            
+            foreach($sets as $kv) {
+                $ret.="<dt>" . $kv['key'] . '</dt><dd>' . str_replace('\n', '<br/>', htmlspecialchars($kv['val'])) . '</dd>';
+            }
+            return $ret;
+        }
+        
+        
+        return implode('<br/>', $lines);
+        
+        
+        
+        
+        
+        
+    }
+    
+}
\ No newline at end of file