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

## Source for file cell.php

Documentation is available at cell.php

1. <?php
2. /**
3. * File containing the ezcConsoleTableCell 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. * Representation of a table cell.
30. * An object of this class represents a table cell. A cell has a certain content,
31. * may apply a format to this data, align the data in the cell and so on.
32. *
33. * This class stores the cells for the {@link ezcConsoleTable} class.
34. *
35. * @see ezcConsoleTableRow
36. *
37. * @property string $content
38. * Text displayed in the cell.
39. * @property string $format
40. * Format applied to the displayed text.
41. * @property int $align
42. * Alignment of the text inside the cell. Must be one of
43. * ezcConsoleTable::ALIGN_ constants. See
44. * {@link ezcConsoleTable::ALIGN_LEFT},
45. * {@link ezcConsoleTable::ALIGN_RIGHT} and
46. * {@link ezcConsoleTable::ALIGN_CENTER}.
47. *
48. * @package ConsoleTools
49. * @version //autogen//
50. */
51. class ezcConsoleTableCell
52. {
53. /**
54. * Container to hold the properties
55. *
56. * @var array(string=>mixed)
57. */
58. protected $properties ;
60. /**
61. * Create a new ezcConsoleProgressbarCell.
62. * Creates a new ezcConsoleProgressbarCell. You can either submit the cell
63. * data through the constructor or set them as properties.
64. *
65. * @param string $content Content of the cell.
66. * @param string $format Format to display the cell with.
67. * @param mixed $align Alignment of the content in the cell.
68. * @return void
69. */
70. public function __construct ( $content = '', $format = 'default', $align = ezcConsoleTable::ALIGN_DEFAULT )
71. {
72. $this->__set( 'content', $content );
73. $this->__set( 'format', $format );
74. $this->__set( 'align', $align );
75. }
77. /**
78. * Property read access.
79. *
80. * @param string $key Name of the property.
81. * @return mixed Value of the property or null.
82. *
83. * @throws ezcBasePropertyNotFoundException
84. * If the the desired property is not found.
85. * @ignore
86. */
87. public function __get( $key )
88. {
89. if ( isset( $this-> properties [$key] ) )
90. {
91. return $this-> properties [$key];
92. }
93. throw new ezcBasePropertyNotFoundException ( $key );
94. }
96. /**
97. * Property write access.
98. *
99. * @param string $key Name of the property.
100. * @param mixed $val The value for the property.
101. *
102. * @throws ezcBaseValueException
103. * If a the value submitted for the align is not in the range of
104. * {@link ezcConsoleTable::ALIGN_LEFT},
105. * {@link ezcConsoleTable::ALIGN_CENTER},
106. * {@link ezcConsoleTable::ALIGN_RIGHT},
107. * {@link ezcConsoleTable::ALIGN_DEFAULT}
108. *
109. * @ignore
110. */
111. public function __set( $key, $val )
112. {
114. switch ( $key )
115. {
116. case 'content':
117. if ( is_string ( $val ) === false )
118. {
119. throw new ezcBaseValueException ( $key, $val, "string" );
120. }
121. break;
122. case 'format':
123. if ( is_string ( $val ) === false || strlen ( $val ) < 1 )
124. {
125. throw new ezcBaseValueException ( $key, $val, "string, length > 0" );
126. }
127. break;
128. case 'align':
129. if ( $val !== ezcConsoleTable ::ALIGN_LEFT
130. && $val !== ezcConsoleTable ::ALIGN_CENTER
131. && $val !== ezcConsoleTable ::ALIGN_RIGHT
132. && $val !== ezcConsoleTable ::ALIGN_DEFAULT
133. )
134. {
135. throw new ezcBaseValueException ( $key, $val, 'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
136. }
137. break;
138. default:
139. throw new ezcBasePropertyNotFoundException ( $key );
140. }
141. $this-> properties [$key] = $val;
142. return;
143. }
145. /**
146. * Property isset access.
147. *
148. * @param string $key Name of the property.
149. * @return bool True is the property is set, otherwise false.
150. * @ignore
151. */
152. public function __isset( $key )
153. {
154. switch ( $key )
155. {
156. case 'content':
157. case 'format':
158. case 'align':
159. return true;
160. default:
161. break;
162. }
163. return false;
164. }
166. }
168. ?>

Documentation generated by phpDocumentor 1.4.3