<?php
 
/**
 
 * @package DATA
 
 */
 
 
/**
 
 * An exception thrown when a sql decimal field is filled with an
 
 * invalid value or has overflown its capacity.
 
 */
 
class DATA_InvalidDecimal extends DATA_SQLTypeConstraintFailed {
 
    /**
 
     * How many digits the field could hold.
 
     * @var int
 
     */
 
    private $expectedPrecision;
 
    /**
 
     * How many digits the field had after decimal point.
 
     * @var int
 
     */
 
    private $expectedScale;
 
    /**
 
     * The string that failed the constraint.
 
     * @var string
 
     */
 
    private $providedNumber;
 
    
 
    /**
 
     * Constructor.
 
     * 
 
     * @param int $expectedPrecision How many digits the field could hold.
 
     * @param int $expectedScale How many digits the field had after decimal point.
 
     * @param string $providedNumber The string that failed the constraint.
 
     */
 
    public function __construct($expectedPrecision, $expectedScale, $providedNumber) {
 
        parent::__construct("SQL numeric field of $expectedPrecision digits with $expectedScale decimals cannot hold '$providedNumber'");
 
        $this->expectedPrecision = $expectedPrecision;
 
        $this->expectedScale = $expectedScale;
 
        $this->providedNumber = $providedNumber;
 
    }
 
    
 
    /**
 
     * Returns how many digits the field could hold.
 
     * 
 
     * @return int How many digits the field could hold.
 
     */
 
    public function getExpectedPrecision() {
 
        return $this->expectedPrecision;
 
    }
 
    
 
    /**
 
     * Returns how many digits the field had after decimal point.
 
     * 
 
     * @return int How many digits the field had after decimal point.
 
     */
 
    public function getExpectedScale() {
 
        return $this->expectedScale;
 
    }
 
    
 
    /**
 
     * Returns the string that failed the constraint.
 
     * 
 
     * @return string The string that failed the constraint.
 
     */
 
    public function getProvidedNumber() {
 
        return $this->providedNumber;
 
    }
 
}
 
?>
 
 
 |