<?php
/**
* @package DATA
*/
/**
* A concrete factory for inboxing php values into small int fields.
*/
class DATA_SQLSmallIntFactory extends DATA_SQLTypeFactory {
/**
* Flags the type to nullable or not nullable.
* @var boolean
*/
private $nullable;
/**
* Constructor.
*
* @param boolean $nullable True if the type is nullable.
*/
public function __construct($nullable) {
$this->nullable = $nullable;
}
/**
* Inboxes a value.
*
* Throws {@link DATA_InvalidInt}.
*
* @param mixed $value The value.
* @return DATA_SQLInt Inboxed value.
*/
public function inbox($value) {
if ($value instanceof DATA_SQLSmallInt) {
if ($this->nullable == $value->isNullable()) {
return clone $value;
}
}
if ($value instanceof DATA_SQLType) {
$value = $value->outbox();
}
return new DATA_SQLSmallInt($this->nullable, $value);
}
}
?>
|