summaryrefslogtreecommitdiffstats
path: root/src/options/chart.php
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/options/chart.php
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/options/chart.php')
-rw-r--r--src/options/chart.php20
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;
OpenPOWER on IntegriCloud