ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilXMLResultSetRow.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  +-----------------------------------------------------------------------------+
7  | ILIAS open source |
8  +-----------------------------------------------------------------------------+
9  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
10  | |
11  | This program is free software; you can redistribute it and/or |
12  | modify it under the terms of the GNU General Public License |
13  | as published by the Free Software Foundation; either version 2 |
14  | of the License, or (at your option) any later version. |
15  | |
16  | This program is distributed in the hope that it will be useful, |
17  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19  | GNU General Public License for more details. |
20  | |
21  | You should have received a copy of the GNU General Public License |
22  | along with this program; if not, write to the Free Software |
23  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24  +-----------------------------------------------------------------------------+
25 */
26 
32 {
34  private array $columns = [];
35 
42  public function setValue($index, string $value): void
43  {
44  $this->columns[$index] = $value;
45  }
46 
50  public function getColumns(): array
51  {
52  return $this->columns;
53  }
54 
58  public function setValues(array $values): void
59  {
60  $i = 0;
61  foreach ($values as $value) {
62  $this->setValue($i++, (string) $value);
63  }
64  }
65 
71  public function getValue($idx): string
72  {
73  if (is_string($idx) && !array_key_exists($idx, $this->columns)) {
74  throw new DomainException('Invalid index given: ' . $idx);
75  }
76 
77  if (is_int($idx) &&
78  ($idx < 0 || $idx >= count($this->columns))) {
79  throw new DomainException("Index too small or too large: " . $idx);
80  }
81 
82  return $this->columns[$idx];
83  }
84 }
Row Class for XMLResultSet.
setValue($index, string $value)
set column value
setValues(array $values)
Set values from array.
getValue($idx)
Return value for column with specified index.