diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-11-02 16:05:45 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-11-02 16:05:45 +0000 |
commit | 5bdf51ead2a5e1dfb683c56df48e3d887e743472 (patch) | |
tree | 7e39889aca43eff30617df44f5bb567be94035f9 /src/options/chart.php | |
parent | 39d55ef60b9074920a1a3fc3d0c0f8d51f303760 (diff) | |
download | zetacomponents-graph-5bdf51ead2a5e1dfb683c56df48e3d887e743472.zip zetacomponents-graph-5bdf51ead2a5e1dfb683c56df48e3d887e743472.tar.gz |
- Throw ezcBaseValueExceptions instead of typecasting
- Do range checks instead of converting numbers using min and max
- Extended testcases to test for ezcBaseValueExceptions
Diffstat (limited to 'src/options/chart.php')
-rw-r--r-- | src/options/chart.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/options/chart.php b/src/options/chart.php index 4d6139d..ae9bd9f 100644 --- a/src/options/chart.php +++ b/src/options/chart.php @@ -23,8 +23,8 @@ class ezcGraphChartOptions extends ezcBaseOptions { public function __construct( array $options = array() ) { - $this->properties['width'] = false; - $this->properties['height'] = false; + $this->properties['width'] = null; + $this->properties['height'] = null; $this->properties['font'] = new ezcGraphFontOptions(); parent::__construct( $options ); @@ -44,10 +44,22 @@ class ezcGraphChartOptions extends ezcBaseOptions switch ( $propertyName ) { case 'width': - $this->properties['width'] = max( 1, (int) $propertyValue ); + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 1 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' ); + } + + $this->properties['width'] = (int) $propertyValue; break; case 'height': - $this->properties['height'] = max( 1, (int) $propertyValue ); + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 1 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' ); + } + + $this->properties['height'] = (int) $propertyValue; break; case 'font': $this->properties['font']->path = $propertyValue; |