PHP Classes

File: DATA/SQLSmallIntFactory.php

Recommend this page to a friend!
  Classes of Martin Alterisio   DATA   DATA/SQLSmallIntFactory.php   Download  
File: DATA/SQLSmallIntFactory.php
Role: Class source
Content type: text/plain
Description: A concrete factory for inboxing php values into small int fields.
Class: DATA
Access data stored in MySQL tables like arrays
Author: By
Last change: + anonymous access
Date: 16 years ago
Size: 1,077 bytes
 

Contents

Class file image Download
<?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);
    }
}
?>