PHP Classes
elePHPant
Icontem

File: DATA/SQLIntFactory.php

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

Contents

Class file image Download
<?php
/**
 * @package DATA
 */

/**
 * A concrete factory for inboxing php values into int fields.
 */
class DATA_SQLIntFactory 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_SQLInt) {
            if (
$this->nullable == $value->isNullable()) {
                return clone
$value;
            }
        }
        if (
$value instanceof DATA_SQLType) {
           
$value = $value->outbox();
        }
        return new
DATA_SQLInt($this->nullable, $value);
    }
}
?>