10
10
*/
11
11
12
12
13
- /** @ingroup Examples
13
+ /** @ingroup SPL
14
14
* @brief RecursiveIteratorIterator to generate ASCII graphic trees for the
15
15
* entries in a RecursiveIterator
16
16
* @author Marcus Boerger, Johannes Schlueter
17
- * @version 1.0
17
+ * @version 1.1
18
+ * @since PHP 5.3
18
19
*/
19
20
class RecursiveTreeIterator extends RecursiveIteratorIterator
20
21
{
@@ -35,16 +36,34 @@ class RecursiveTreeIterator extends RecursiveIteratorIterator
35
36
$ this ->rit_flags = $ rit_flags ;
36
37
}
37
38
38
- /** Prefix strings used in getPrefix()
39
- *
40
- * 0: prefix used to start elements
41
- * 1: prefix used if $level < depth and hasNext($level) == true
42
- * 2: prefix used if $level < depth and hasNext($level) == false
43
- * 3: prefix used if $level == depth and hasNext($level) == true
44
- * 4: prefix used if $level == depth and hasNext($level) == false
45
- * 5: prefix used right in front of the current element
39
+ private $ prefix = array (0 =>'' , 1 =>'| ' , 2 =>' ' , 3 =>'|- ' , 4 =>'\- ' , 5 =>'' );
40
+
41
+ /** Prefix used to start elements. */
42
+ const PREFIX_LEFT = 0 ;
43
+ /** Prefix used if $level < depth and hasNext($level) == true. */
44
+ const PREFIX_MID_HAS_NEXT = 1 ;
45
+ /** Prefix used if $level < depth and hasNext($level) == false. */
46
+ const PREFIX_MID_LAST = 2 ;
47
+ /** Prefix used if $level == depth and hasNext($level) == true. */
48
+ const PREFIX_END_HAS_NEXT = 3 ;
49
+ /** Prefix used if $level == depth and hasNext($level) == false. */
50
+ const PREFIX_END_LAST = 4 ;
51
+ /** Prefix used right in front of the current element. */
52
+ const PREFIX_RIGHT = 5 ;
53
+
54
+ /**
55
+ * Set prefix part as used in getPrefix() and stored in $prefix.
56
+ * @param $part any PREFIX_* const.
57
+ * @param $value new prefix string for specified part.
58
+ * @throws OutOfRangeException if 0 > $part or $part > 5.
46
59
*/
47
- public $ prefix = array (0 =>'' , 1 =>'| ' , 2 =>' ' , 3 =>'|- ' , 4 =>'\- ' , 5 =>'' );
60
+ function setPrefixPart ($ part , $ value )
61
+ {
62
+ if (0 > $ part || $ part > 5 ) {
63
+ throw new OutOfRangeException ();
64
+ }
65
+ $ this ->prefix [$ part ] = (string )$ value ;
66
+ }
48
67
49
68
/** @return string to place in front of current element
50
69
*/
0 commit comments