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/datasets | |
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/datasets')
-rw-r--r-- | src/datasets/average.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/datasets/average.php b/src/datasets/average.php index 33dfa71..0f4e4f1 100644 --- a/src/datasets/average.php +++ b/src/datasets/average.php @@ -96,11 +96,23 @@ class ezcGraphDataSetAveragePolynom extends ezcGraphDataSet { switch ( $propertyName ) { case 'polynomOrder': + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 0 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 0' ); + } + $this->properties['polynomOrder'] = (int) $propertyValue; $this->polynom = false; break; case 'resolution': - $this->properties['resolution'] = max( 1, (int) $propertyValue ); + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 1 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 1' ); + } + + $this->properties['resolution'] = (int) $propertyValue; break; default: parent::__set( $propertyName, $propertyValue ); |