summaryrefslogtreecommitdiffstats
path: root/src/datasets
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-11-02 16:05:45 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-11-02 16:05:45 +0000
commit5bdf51ead2a5e1dfb683c56df48e3d887e743472 (patch)
tree7e39889aca43eff30617df44f5bb567be94035f9 /src/datasets
parent39d55ef60b9074920a1a3fc3d0c0f8d51f303760 (diff)
downloadzetacomponents-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.php14
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 );
OpenPOWER on IntegriCloud