## Apache Zeta Components Manual :: File Source for progressbar.php

## Source for file progressbar.php

Documentation is available at progressbar.php

1. <?php
2. /**
3. * File containing the ezcConsoleProgressbarOptions class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package ConsoleTools
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Struct class to store the options of the ezcConsoleOutput class.
30. * This class stores the options for the {@link ezcConsoleOutput} class.
31. *
32. * @property string $barChar
33. * The character to fill the bar with, during progress indication.
34. * @property string $emptyChar
35. * The character to pre-fill the bar, before indicating progress.
36. * @property string $formatString
37. * The format string to describe the complete progressbar.
38. * @property string $fractionFormat
39. * Format to display the fraction value.
40. * @property string $processChar
41. * The character for the end of the progress area (the arrow!).
42. * @property int $redrawFrequency
43. * How often to redraw the progressbar (on every Xth call to advance()).
44. * @property int $step
45. * How many steps to advance the progressbar on each call to advance().
46. * @property int $width
47. * The width of the bar itself.
48. * @property string $actFormat
49. * The format to display the actual value with.
50. * @property string $maxFormat
51. * The format to display the actual value with.
52. * @property int $minVerbosity
53. * Defines the minimum {ezcConsoleOutputOptions->$verbosityLevel}
54. * that is needed by the progress bar to be rendered. If
55. * $verbosityLevel is lower, the bar is skipped. Default is 0 to
56. * render always.
57. * @property int $maxVerbosity
58. * Defines the maximum {ezcConsoleOutputOptions->$verbosityLevel} on
59. * which the progress bar is rendered. If $verbosityLevel is higher,
60. * the bar is skipped. Default is false, to render always.
61. *
62. * @package ConsoleTools
63. * @version //autogen//
64. */
65. class ezcConsoleProgressbarOptions extends ezcBaseOptions
66. {
68. protected $properties = array(
69. 'barChar' => "+",
70. 'emptyChar' => "-",
71. 'formatString' => "%act% / %max% [%bar%] %fraction%%",
72. 'fractionFormat' => "%01.2f",
73. 'progressChar' => ">",
74. 'redrawFrequency' => 1,
75. 'step' => 1,
76. 'width' => 78,
77. 'actFormat' => '%.0f',
78. 'maxFormat' => '%.0f',
79. 'minVerbosity' => 1,
80. 'maxVerbosity' => false,
81. );
83. /**
84. * Option write access.
85. *
86. * @throws ezcBasePropertyNotFoundException
87. * If a desired property could not be found.
88. * @throws ezcBaseValueException
89. * If a desired property value is out of range.
90. *
91. * @param string $key Name of the property.
92. * @param mixed $value The value for the property.
93. * @ignore
94. */
95. public function __set( $key, $value )
96. {
97. switch ( $key )
98. {
99. case "barChar":
100. case "emptyChar":
101. case "progressChar":
102. case "formatString":
103. case "fractionFormat":
104. case "actFormat":
105. case "maxFormat":
106. if ( is_string ( $value ) === false || strlen ( $value ) < 1 )
107. {
108. throw new ezcBaseValueException ( $key, $value, 'string, not empty' );
109. }
110. break;
111. case "width":
112. if ( ! is_int ( $value ) || $value < 5 )
113. {
114. throw new ezcBaseValueException ( $key, $value, 'int >= 5' );
115. }
116. break;
117. case "redrawFrequency":
118. case "step":
119. if ( ( ! is_int ( $value ) && ! is_float ( $value ) ) || $value < 1 )
120. {
121. throw new ezcBaseValueException ( $key, $value, 'int > 0' );
122. }
123. break;
124. case 'minVerbosity':
125. if ( ! is_int ( $value ) || $value < 0 )
126. {
127. throw new ezcBaseValueException ( $key, $value, 'int >= 0' );
128. }
129. break;
130. case 'maxVerbosity':
131. if ( ( ! is_int ( $value ) || $value < 0 ) && $value !== false )
132. {
133. throw new ezcBaseValueException ( $key, $value, 'int >= 0 or false' );
134. }
135. break;
136. default:
137. throw new ezcBasePropertyNotFoundException ( $key );
138. }
139. $this-> properties [$key] = $value;
140. }
141. }
143. ?>

Documentation generated by phpDocumentor 1.4.3