/** * Set an option value * * @param string $propertyName * @param mixed $propertyValue * @throws ezcBasePropertyNotFoundException * If a property is not defined in this class * @return void * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'imageMapResolution': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1'); } $this->properties['imageMapResolution'] = (int) $propertyValue; break; case 'circleResolution': if (!is_numeric($propertyValue) || $propertyValue <= 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties['circleResolution'] = (double) $propertyValue; break; default: parent::__set($propertyName, $propertyValue); break; } }
/** * Set an option value * * @param string $propertyName * @param mixed $propertyValue * @throws ezcBasePropertyNotFoundException * If a property is not defined in this class * @return void */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'imageFormat': if (imagetypes() & $propertyValue) { $this->properties['imageFormat'] = (int) $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'Unsupported image type.'); } break; case 'jpegQuality': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 100) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= int <= 100'); } $this->properties['jpegQuality'] = (int) $propertyValue; break; case 'detail': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1'); } $this->properties['detail'] = (int) $propertyValue; break; case 'supersampling': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1'); } $this->properties['supersampling'] = (int) $propertyValue; break; case 'background': if ($propertyValue === false || is_file($propertyValue) && is_readable($propertyValue)) { $this->properties['background'] = realpath($propertyValue); } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'readable file'); } break; case 'resampleFunction': if (ezcBaseFeatures::hasFunction($propertyValue)) { $this->properties['resampleFunction'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'function'); } break; case 'forceNativeTTF': if (!is_bool($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'bool'); } $this->properties['forceNativeTTF'] = (bool) $propertyValue; break; case 'imageMapResolution': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1'); } $this->properties['imageMapResolution'] = (int) $propertyValue; break; default: parent::__set($propertyName, $propertyValue); break; } }
/** * Set an option value * * @param string $propertyName * @param mixed $propertyValue * @throws ezcBasePropertyNotFoundException * If a property is not defined in this class * @return void * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'assumedNumericCharacterWidth': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties['assumedNumericCharacterWidth'] = (double) $propertyValue; break; case 'assumedTextCharacterWidth': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties['assumedTextCharacterWidth'] = (double) $propertyValue; break; case 'strokeLineJoin': $values = array('round', 'miter', 'bevel', 'inherit'); if (in_array($propertyValue, $values, true)) { $this->properties['strokeLineJoin'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, implode($values, ', ')); } break; case 'strokeLineCap': $values = array('round', 'butt', 'square', 'inherit'); if (in_array($propertyValue, $values, true)) { $this->properties['strokeLineCap'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, implode($values, ', ')); } break; case 'shapeRendering': $values = array('auto', 'optimizeSpeed', 'crispEdges', 'geometricPrecision', 'inherit'); if (in_array($propertyValue, $values, true)) { $this->properties['shapeRendering'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, implode($values, ', ')); } break; case 'colorRendering': $values = array('auto', 'optimizeSpeed', 'optimizeQuality', 'inherit'); if (in_array($propertyValue, $values, true)) { $this->properties['colorRendering'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, implode($values, ', ')); } break; case 'textRendering': $values = array('auto', 'optimizeSpeed', 'optimizeLegibility', 'geometricPrecision', 'inherit'); if (in_array($propertyValue, $values, true)) { $this->properties['textRendering'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, implode($values, ', ')); } break; case 'templateDocument': if (!is_file($propertyValue) || !is_readable($propertyValue)) { throw new ezcBaseFileNotFoundException($propertyValue); } else { $this->properties['templateDocument'] = realpath($propertyValue); } break; case 'insertIntoGroup': if (!is_string($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'string'); } else { $this->properties['insertIntoGroup'] = $propertyValue; } break; case 'graphOffset': if ($propertyValue instanceof ezcGraphCoordinate) { $this->properties['graphOffset'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphCoordinate'); } break; case 'idPrefix': $this->properties['idPrefix'] = (string) $propertyValue; break; case 'encoding': $this->properties['encoding'] = (string) $propertyValue; break; case 'linkCursor': $this->properties['linkCursor'] = (string) $propertyValue; break; default: parent::__set($propertyName, $propertyValue); break; } }
/** * Set an option value * * @param string $propertyName * @param mixed $propertyValue * @throws ezcBasePropertyNotFoundException * If a property is not defined in this class * @return void * @ignore */ public function __set($propertyName, $propertyValue) { 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'] = (double) $propertyValue; break; default: parent::__set($propertyName, $propertyValue); break; } }