@@ -159,7 +159,7 @@ public function getValue(int $rowIndex, int $colIndex) {
159159 if ($ cell != null ) {
160160 $ ch = $ cell ->getChild (0 );
161161
162- if ($ ch ->getName () == '#TEXT ' ) {
162+ if ($ ch ->getNodeName () == '#TEXT ' ) {
163163 return $ ch ->getText ();
164164 }
165165
@@ -170,6 +170,8 @@ public function getValue(int $rowIndex, int $colIndex) {
170170 /**
171171 * Removes a column from the table given column index.
172172 *
173+ * Note that if the table has one column, the method will not remove it.
174+ *
173175 * @param int $colIndex The index of the column.
174176 *
175177 * @return array The method will return an array that holds objects that
@@ -179,25 +181,36 @@ public function getValue(int $rowIndex, int $colIndex) {
179181 public function removeCol (int $ colIndex ) : array {
180182 $ colCells = [];
181183
182- if ($ colIndex < $ this ->cols ()) {
184+ if ($ colIndex < $ this ->cols () && $ this -> cols () > 1 ) {
183185 foreach ($ this as $ row ) {
184186 $ colCells [] = $ row ->children ()->remove ($ colIndex );
185187 }
188+ $ this ->cols --;
186189 }
187190
188191 return $ colCells ;
189192 }
190193 /**
191194 * Removes a row given its index.
192195 *
196+ * Note that if the table has only one row, the method will not remove it.
197+ *
193198 * @param int $rowIndex The index of the row.
194199 *
195200 * @return TableRow|null If the row is removed, the method will return
196201 * an object that represents the removed row. Other than that, the method
197202 * will return null.
198203 */
199204 public function removeRow (int $ rowIndex ) {
200- return $ this ->removeChild ($ rowIndex );
205+ if ($ this ->rows () > 1 ) {
206+ $ row = $ this ->removeChild ($ rowIndex );
207+
208+ if ($ row !== null ) {
209+ $ this ->rows --;
210+ }
211+
212+ return $ row ;
213+ }
201214 }
202215 /**
203216 * Returns number of rows in the table.
0 commit comments