<?php
 
/**
 
 * @package DATA
 
 */
 
 
/**
 
 * An exception thrown when a sql character field cannot hold
 
 * the string provided by the user.
 
 */
 
class DATA_StringTooLarge extends DATA_SQLTypeConstraintFailed {
 
    /**
 
     * The maximum size that was expected.
 
     * @var int
 
     */
 
    private $expectedSize;
 
    /**
 
     * The string that failed the constraint.
 
     * @var string
 
     */
 
    private $providedString;
 
    
 
    /**
 
     * Constructor.
 
     * 
 
     * @param int $expectedSize The maximum size that was expected.
 
     * @param string $providedString The string that failed the constraint.
 
     */
 
    public function __construct($expectedSize, $providedString) {
 
        parent::__construct("SQL char field of $expectedSize characters cannot hold '$providedString'");
 
        $this->expectedSize = $expectedSize;
 
        $this->providedString = $providedString;
 
    }
 
    
 
    /**
 
     * Returns the maximum size expected.
 
     * 
 
     * @return int Maximum size expected.
 
     */
 
    public function getExpectedSize() {
 
        return $this->expectedSize;
 
    }
 
    
 
    /**
 
     * Returns the string that failed the constraint.
 
     * 
 
     * @return string String that failed the constraint.
 
     */
 
    public function getProvidedString() {
 
        return $this->providedString;
 
    }
 
}
 
?>
 
 
 |