summaryrefslogtreecommitdiffstats
path: root/src/options
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
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')
-rw-r--r--src/options/chart.php20
-rw-r--r--src/options/driver.php38
-rw-r--r--src/options/font.php48
-rw-r--r--src/options/gd_driver.php38
-rw-r--r--src/options/line_chart.php37
-rw-r--r--src/options/ming_driver.php13
-rw-r--r--src/options/pie_chart.php23
-rw-r--r--src/options/renderer.php103
-rw-r--r--src/options/renderer_2d.php17
-rw-r--r--src/options/renderer_3d.php73
-rw-r--r--src/options/svg_driver.php16
11 files changed, 299 insertions, 127 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;
diff --git a/src/options/driver.php b/src/options/driver.php
index d95b490..da6717a 100644
--- a/src/options/driver.php
+++ b/src/options/driver.php
@@ -34,8 +34,8 @@ abstract class ezcGraphDriverOptions 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['lineSpacing'] = .1;
$this->properties['shadeCircularArc'] = .5;
@@ -59,16 +59,42 @@ abstract class ezcGraphDriverOptions 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 'lineSpacing':
- $this->properties['lineSpacing'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['lineSpacing'] = (float) $propertyValue;
break;
case 'shadeCircularArc':
- $this->properties['shadeCircularArc'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['shadeCircularArc'] = (float) $propertyValue;
break;
case 'font':
if ( $propertyValue instanceof ezcGraphFontOptions )
diff --git a/src/options/font.php b/src/options/font.php
index 0a0f135..0f6a3d8 100644
--- a/src/options/font.php
+++ b/src/options/font.php
@@ -97,11 +97,16 @@ class ezcGraphFontOptions extends ezcBaseOptions
switch ( $propertyName )
{
case 'minFontSize':
- $this->properties['minFontSize'] = max( 1, (float) $propertyValue );
- break;
case 'maxFontSize':
- $this->properties['maxFontSize'] = max( 1, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
case 'minimalUsedFont':
$propertyValue = (float) $propertyValue;
if ( $propertyValue < $this->minimalUsedFont )
@@ -109,34 +114,33 @@ class ezcGraphFontOptions extends ezcBaseOptions
$this->properties['minimalUsedFont'] = $propertyValue;
}
break;
- case 'color':
- $this->properties['color'] = ezcGraphColor::create( $propertyValue );
- break;
+ case 'color':
case 'background':
- $this->properties['background'] = ezcGraphColor::create( $propertyValue );
- break;
case 'border':
- $this->properties['border'] = ezcGraphColor::create( $propertyValue );
+ case 'textShadowColor':
+ $this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
+
case 'borderWidth':
- $this->properties['borderWidth'] = (int) $propertyValue;
- break;
case 'padding':
- $this->properties['padding'] = (int) $propertyValue;
+ case 'textShadowOffset':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties[$propertyName] = (int) $propertyValue;
break;
+
case 'minimizeBorder':
- $this->properties['minimizeBorder'] = (bool) $propertyValue;
- break;
-
case 'textShadow':
- $this->properties['textShadow'] = (bool) $propertyValue;
- break;
- case 'textShadowOffset':
- $this->properties['textShadowOffset'] = max( 0, (int) $propertyValue );
- break;
- case 'textShadowColor':
- $this->properties['textShadowColor'] = ezcGraphColor::create( $propertyValue );
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+ $this->properties[$propertyName] = (bool) $propertyValue;
break;
case 'name':
diff --git a/src/options/gd_driver.php b/src/options/gd_driver.php
index f4eec06..37000f7 100644
--- a/src/options/gd_driver.php
+++ b/src/options/gd_driver.php
@@ -79,13 +79,32 @@ class ezcGraphGdDriverOptions extends ezcGraphDriverOptions
}
break;
case 'jpegQuality':
- $this->properties['jpegQuality'] = max( 0, min( 100, (int) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 100 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 100' );
+ }
+
+ $this->properties['jpegQuality'] = (int) $propertyValue;
break;
case 'detail':
- $this->properties['detail'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['detail'] = (int) $propertyValue;
break;
case 'supersampling':
- $this->properties['supersampling'] = (int) max( 1, $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['supersampling'] = (int) $propertyValue;
break;
case 'background':
if ( $propertyValue === false ||
@@ -109,10 +128,21 @@ class ezcGraphGdDriverOptions extends ezcGraphDriverOptions
}
break;
case 'forceNativeTTF':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['forceNativeTTF'] = (bool) $propertyValue;
break;
case 'imageMapResolution':
- $this->properties['imageMapResolution'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['imageMapResolution'] = (int) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
diff --git a/src/options/line_chart.php b/src/options/line_chart.php
index c8497ac..197202a 100644
--- a/src/options/line_chart.php
+++ b/src/options/line_chart.php
@@ -64,20 +64,29 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions
switch ( $propertyName )
{
case 'lineThickness':
- $this->properties['lineThickness'] = max( 1, (int) $propertyValue );
- break;
- case 'fillLines':
- if ( $propertyValue === false )
+ case 'symbolSize':
+ case 'highlightSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
{
- $this->properties['fillLines'] = false;
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
- else
+
+ $this->properties[$propertyName] = (int) $propertyValue;
+ break;
+ case 'fillLines':
+ if ( ( $propertyValue !== false ) &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 255 ) )
{
- $this->properties['fillLines'] = min( 255, max( 0, (int) $propertyValue ) );
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= int <= 255' );
}
- break;
- case 'symbolSize':
- $this->properties['symbolSize'] = max( 1, (int) $propertyValue );
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (int) $propertyValue );
break;
case 'highlightFont':
if ( $propertyValue instanceof ezcGraphFontOptions )
@@ -99,11 +108,15 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
}
break;
- case 'highlightSize':
$this->properties['highlightSize'] = max( 1, (int) $propertyValue );
break;
case 'highlightLines':
- $this->properties['highlightLines'] = (bool) $propertyValue;
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
+ $this->properties['highlightLines'] = $propertyValue;
break;
default:
return parent::__set( $propertyName, $propertyValue );
diff --git a/src/options/ming_driver.php b/src/options/ming_driver.php
index 4e5d1cd..78a9ade 100644
--- a/src/options/ming_driver.php
+++ b/src/options/ming_driver.php
@@ -51,9 +51,22 @@ class ezcGraphMingDriverOptions extends ezcGraphDriverOptions
switch ( $propertyName )
{
case 'compression':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 9 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' );
+ }
+
$this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) );
break;
case 'circleResolution':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['circleResolution'] = (float) $propertyValue;
break;
default:
diff --git a/src/options/pie_chart.php b/src/options/pie_chart.php
index 5974a2d..c52a173 100644
--- a/src/options/pie_chart.php
+++ b/src/options/pie_chart.php
@@ -82,13 +82,32 @@ class ezcGraphPieChartOptions extends ezcGraphChartOptions
}
break;
case 'sum':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['sum'] = (float) $propertyValue;
break;
case 'percentTreshHold':
- $this->properties['percentTreshHold'] = max( .0, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['percentTreshHold'] = (float) $propertyValue;
break;
case 'absoluteTreshHold':
- $this->properties['absoluteTreshHold'] = max( .0, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['absoluteTreshHold'] = (float) $propertyValue;
break;
case 'summarizeCaption':
$this->properties['summarizeCaption'] = (string) $propertyValue;
diff --git a/src/options/renderer.php b/src/options/renderer.php
index 0438730..4940026 100644
--- a/src/options/renderer.php
+++ b/src/options/renderer.php
@@ -103,63 +103,78 @@ class ezcGraphRendererOptions extends ezcGraphChartOptions
{
switch ( $propertyName )
{
- case 'maxLabelHeight':
- $this->properties['maxLabelHeight'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'symbolSize':
- $this->properties['symbolSize'] = (int) $propertyValue;
+ case 'dataBorder':
+ case 'pieChartGleam':
+ case 'legendSymbolGleam':
+ if ( $propertyValue !== false &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (float) $propertyValue );
break;
+
+ case 'maxLabelHeight':
case 'moveOut':
- $this->properties['moveOut'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'showSymbol':
- $this->properties['showSymbol'] = (bool) $propertyValue;
+ case 'barMargin':
+ case 'barPadding':
+ case 'legendSymbolGleamSize':
+ case 'pieVerticalSize':
+ case 'pieHorizontalSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
+ case 'symbolSize':
case 'titlePosition':
- $this->properties['titlePosition'] = (int) $propertyValue;
- break;
case 'titleAlignement':
- $this->properties['titleAlignement'] = (int) $propertyValue;
- break;
- case 'dataBorder':
- $this->properties['dataBorder'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barMargin':
- $this->properties['barMargin'] = min( 1., max( .0, (float) $propertyValue ) );
+ case 'pieChartGleamBorder':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties[$propertyName] = (int) $propertyValue;
break;
- case 'barPadding':
- $this->properties['barPadding'] = min( 1., max( .0, (float) $propertyValue ) );
+
+ case 'showSymbol':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+ $this->properties['showSymbol'] = (bool) $propertyValue;
break;
+
case 'pieChartOffset':
- $this->properties['pieChartOffset'] = $propertyValue % 360;
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 360 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 360' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
case 'pieChartSymbolColor':
- $this->properties['pieChartSymbolColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieChartGleam':
- $this->properties['pieChartGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'pieChartGleamColor':
- $this->properties['pieChartGleamColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieChartGleamBorder':
- $this->properties['pieChartGleamBorder'] = max( 0, (int) $propertyValue );
- break;
- case 'legendSymbolGleam':
- $this->properties['legendSymbolGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'legendSymbolGleamSize':
- $this->properties['legendSymbolGleamSize'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'legendSymbolGleamColor':
- $this->properties['legendSymbolGleamColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieVerticalSize':
- $this->properties['pieVerticalSize'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'pieHorizontalSize':
- $this->properties['pieHorizontalSize'] = min( 1., max( .0, (float) $propertyValue ) );
+ $this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
+
default:
return parent::__set( $propertyName, $propertyValue );
}
diff --git a/src/options/renderer_2d.php b/src/options/renderer_2d.php
index 8539008..3235965 100644
--- a/src/options/renderer_2d.php
+++ b/src/options/renderer_2d.php
@@ -52,10 +52,23 @@ class ezcGraphRenderer2dOptions extends ezcGraphRendererOptions
switch ( $propertyName )
{
case 'pieChartShadowSize':
- $this->properties['pieChartShadowSize'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float >= 0' );
+ }
+
+ $this->properties['pieChartShadowSize'] = (int) $propertyValue;
break;
case 'pieChartShadowTransparency':
- $this->properties['pieChartShadowTransparency'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['pieChartShadowTransparency'] = (float) $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
diff --git a/src/options/renderer_3d.php b/src/options/renderer_3d.php
index ceb1ab6..0887ae2 100644
--- a/src/options/renderer_3d.php
+++ b/src/options/renderer_3d.php
@@ -54,7 +54,7 @@ class ezcGraphRenderer3dOptions extends ezcGraphRendererOptions
$this->properties['fillAxis'] = .8;
$this->properties['fillGrid'] = 0;
$this->properties['depth'] = .1;
- $this->properties['pieChartHeight'] = 10;
+ $this->properties['pieChartHeight'] = 10.;
$this->properties['pieChartRotation'] = .6;
$this->properties['pieChartShadowSize'] = 0;
$this->properties['pieChartShadowTransparency'] = .3;
@@ -82,45 +82,60 @@ class ezcGraphRenderer3dOptions extends ezcGraphRendererOptions
{
switch ( $propertyName )
{
- case 'depth':
- $this->properties['depth'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'seperateLines':
- $this->properties['seperateLines'] = (bool) $propertyValue;
- break;
case 'fillAxis':
- $this->properties['fillAxis'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'fillGrid':
- $this->properties['fillGrid'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'dataBorder':
- $this->properties['dataBorder'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'pieChartHeight':
- $this->properties['pieChartHeight'] = (float) $propertyValue;
+ if ( $propertyValue !== false &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (float) $propertyValue );
break;
+
+ case 'depth':
case 'pieChartRotation':
- $this->properties['pieChartRotation'] = min( 1., max( .0, (float) $propertyValue ) );
+ case 'pieChartShadowTransparency':
+ case 'barDarkenSide':
+ case 'barDarkenTop':
+ case 'barChartGleam':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
+ case 'pieChartHeight':
case 'pieChartShadowSize':
- $this->properties['pieChartShadowSize'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
- case 'pieChartShadowTransparency':
- $this->properties['pieChartShadowTransparency'] = min( 1., max( .0, (float) $propertyValue ) );
+
+ case 'seperateLines':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
+ $this->properties['seperateLines'] = $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
break;
- case 'barDarkenSide':
- $this->properties['barDarkenSide'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barDarkenTop':
- $this->properties['barDarkenTop'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barChartGleam':
- $this->properties['barChartGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
default:
return parent::__set( $propertyName, $propertyValue );
}
diff --git a/src/options/svg_driver.php b/src/options/svg_driver.php
index 1a72f6e..27bc597 100644
--- a/src/options/svg_driver.php
+++ b/src/options/svg_driver.php
@@ -91,10 +91,22 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions
switch ( $propertyName )
{
case 'assumedNumericCharacterWidth':
- $this->properties['assumedNumericCharacterWidth'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['assumedNumericCharacterWidth'] = (float) $propertyValue;
break;
case 'assumedTextCharacterWidth':
- $this->properties['assumedTextCharacterWidth'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['assumedTextCharacterWidth'] = (float) $propertyValue;
break;
case 'strokeLineJoin':
$values = array(
OpenPOWER on IntegriCloud