"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mrbs-1.9.4/web/lib/MRBS/Columns.php" between
mrbs-1.9.4.tar.gz and mrbs-1.10.0.tar.gz

About: MRBS is a web application for booking meeting rooms or other resources (using PHP and MySQL/pgsql).

Columns.php  (mrbs-1.9.4):Columns.php  (mrbs-1.10.0)
<?php <?php
namespace MRBS; namespace MRBS;
use Countable;
use Iterator;
// Holds information about table columns // Holds information about table columns
class Columns implements \Countable, \Iterator class Columns implements Countable, Iterator
{ {
private $data; private $data;
private $index = 0; private $index = 0;
private $table_name; private $table_name;
public function __construct($table_name) public function __construct($table_name)
{ {
$this->$table_name = $table_name; $this->$table_name = $table_name;
// Get the column info // Get the column info
$this->data = db()->field_info($table_name); $this->data = db()->field_info($table_name);
} }
public function getNames() public function getNames() : array
{ {
$result = array(); $result = array();
foreach ($this as $column) foreach ($this as $column)
{ {
$result[] = $column->name; $result[] = $column->name;
} }
return $result; return $result;
} }
public function hasIdColumn() public function hasIdColumn() : bool
{ {
$column = $this->getColumnByName('id'); $column = $this->getColumnByName('id');
return isset($column); return isset($column);
} }
public function getColumnByName($name) public function getColumnByName($name) : ?Column
{ {
foreach ($this as $column) foreach ($this as $column)
{ {
if ($column->name == $name) if ($column->name == $name)
{ {
return $column; return $column;
} }
} }
return null; return null;
} }
public function current() public function current() : Column
{ {
$info = $this->data[$this->index]; $info = $this->data[$this->index];
$column = new Column($this->table_name, $info['name']); $column = new Column($this->table_name, $info['name']);
$column->setLength($info['length']); $column->setLength($info['length']);
switch ($info['nature']) switch ($info['nature'])
{ {
case 'binary': case 'binary':
$column->setNature(Column::NATURE_BINARY); $column->setNature(Column::NATURE_BINARY);
break; break;
skipping to change at line 87 skipping to change at line 90
$column->setNature(Column::NATURE_TIMESTAMP); $column->setNature(Column::NATURE_TIMESTAMP);
break; break;
default: default:
throw new \Exception("Unknown nature '" . $info['nature'] . "'"); throw new \Exception("Unknown nature '" . $info['nature'] . "'");
break; break;
} }
return $column; return $column;
} }
public function next() public function next() : void
{ {
$this->index++; $this->index++;
} }
public function key() public function key() : int
{ {
return $this->index; return $this->index;
} }
public function valid() public function valid() : bool
{ {
return isset($this->data[$this->key()]); return isset($this->data[$this->key()]);
} }
public function rewind() public function rewind() : void
{ {
$this->index = 0; $this->index = 0;
} }
public function count() public function count(): int
{ {
return count($this->data); return count($this->data);
} }
} }
 End of changes. 11 change blocks. 
10 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)