Author: Tobias Schlitt
Date: 2006-01-13 15:31:19 +0100 (Fri, 13 Jan 2006)
New Revision: 1832
Log:
- Migrated to new ezcBase* exceptions.
- Implemented value checks for all filters.
Modified:
packages/ImageConversion/trunk/src/exceptions/file_not_processable.php
packages/ImageConversion/trunk/src/filters/gd.php
packages/ImageConversion/trunk/src/filters/imagemagick.php
packages/ImageConversion/trunk/src/handlers/gd.php
packages/ImageConversion/trunk/src/handlers/imagemagick.php
packages/ImageConversion/trunk/src/interfaces/colorspace.php
packages/ImageConversion/trunk/src/interfaces/effect.php
packages/ImageConversion/trunk/src/interfaces/geometry.php
packages/ImageConversion/trunk/src/interfaces/handler.php
packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
packages/ImageConversion/trunk/src/transformation.php
packages/ImageConversion/trunk/tests/handlergd_test.php
packages/ImageConversion/trunk/tests/handlershell_test.php
Modified: packages/ImageConversion/trunk/src/exceptions/file_not_processable.php
===================================================================
--- packages/ImageConversion/trunk/src/exceptions/file_not_processable.php
2006-01-13 14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/exceptions/file_not_processable.php
2006-01-13 14:31:19 UTC (rev 1832)
@@ -18,7 +18,7 @@
{
function __construct( $file, $reason = null )
{
- parent::__construct( "Handler class <{$handlerClass}> not found.", (
$reason !== null ? " $reason" : "" ) );
+ parent::__construct( "Handler class <{$handlerClass}> not found." . (
$reason !== null ? " $reason" : "" ) );
}
}
Modified: packages/ImageConversion/trunk/src/filters/gd.php
===================================================================
--- packages/ImageConversion/trunk/src/filters/gd.php 2006-01-13 14:14:40 UTC
(rev 1831)
+++ packages/ImageConversion/trunk/src/filters/gd.php 2006-01-13 14:31:19 UTC
(rev 1832)
@@ -60,9 +60,21 @@
* If no valid resource for the active reference could be found.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scale( $width, $height, $direction =
ezcImageGeometryFilters::SCALE_BOTH )
{
+
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+
$resource = $this->handler->getActiveResource();
$oldDim = array( 'x' => imagesx( $resource ), 'y' => imagesy(
$resource ) );
@@ -80,7 +92,9 @@
$ratio = $ratio > 1 ? $ratio : 1;
break;
case self::SCALE_BOTH:
+ break;
default:
+ throw new ezcBaseValueException( 'direction', $direction,
'self::SCALE_BOTH, self::SCALE_UP, self::SCALE_DOWN' );
break;
}
$newDim = array(
@@ -105,9 +119,16 @@
* If no valid resource for the active reference could be found.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleWidth( $width, $direction )
{
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
+
$resource = $this->handler->getActiveResource();
$oldDim = array(
'x' => imagesx( $resource ),
@@ -133,6 +154,9 @@
'y' => $width < $oldDim['x'] ? round( $width /
$oldDim['x'] * $oldDim['y'] ) : $oldDim['y'],
);
break;
+ default:
+ throw new ezcBaseValueException( 'direction', $direction,
'self::SCALE_BOTH, self::SCALE_UP, self::SCALE_DOWN' );
+ break;
}
$this->performScale( $newDim );
}
@@ -152,9 +176,16 @@
* If no valid resource for the active reference could be found.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleHeight( $height, $direction )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+
$resource = $this->handler->getActiveResource();
$oldDim = array(
'x' => imagesx( $resource ),
@@ -180,6 +211,9 @@
'y' => min( $height, $oldDim['y'] ),
);
break;
+ default:
+ throw new ezcBaseValueException( 'direction', $direction,
'self::SCALE_BOTH, self::SCALE_UP, self::SCALE_DOWN' );
+ break;
}
$this->performScale( $newDim );
}
@@ -196,9 +230,20 @@
* If no valid resource for the active reference could be found.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scalePercent( $width, $height )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
+
$resource = $this->handler->getActiveResource();
$newDim = array(
'x' => round( imagesx( $resource ) * $width / 100 ),
@@ -218,9 +263,19 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleExact( $width, $height )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
$this->performScale( array( 'x' => $width, 'y' => $height ) );
}
@@ -242,9 +297,28 @@
* If no valid resource for the active reference could be found.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function crop( $x, $y, $width, $height )
{
+ if ( !is_int( $x ) || $x < 1 )
+ {
+ throw new ezcBaseValueException( 'x', $x, 'int > 0' );
+ }
+ if ( !is_int( $y ) || $y < 1 )
+ {
+ throw new ezcBaseValueException( 'y', $y, 'int > 0' );
+ }
+ if ( !is_int( $height ) )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int' );
+ }
+ if ( !is_int( $width ) )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int' );
+ }
+
$oldResource = $this->handler->getActiveResource();
$dimensions = array(
'x' => abs( $width ),
@@ -292,9 +366,9 @@
*
* @param int $space Colorspace, one of self::COLORSPACE_* constants.
*
- * @throws ezcImageInvalidFilterParameterException
+ * @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageInvalidFilterParameterException
+ * @throws ezcBaseValueException
* If the parameter submitted as the colorspace was not within the
* self::COLORSPACE_* constants.
* @throws ezcImageFilterFailedException
@@ -320,7 +394,7 @@
$this->luminanceColorScale( array( 1.0, 0.89, 0.74 ) );
break;
default:
- throw new ezcImageInvalidFilterParameterException(
'colorspace', 'space', $space, self::COLORSPACE_GREY . ', ' .
self::COLORSPACE_SEPIA . ', ' . self::COLORSPACE_MONOCHROME );
+ throw new ezcBaseValueException( 'space', $space,
'self::COLORSPACE_GREY, self::COLORSPACE_SEPIA, self::COLORSPACE_MONOCHROME' );
break;
}
Modified: packages/ImageConversion/trunk/src/filters/imagemagick.php
===================================================================
--- packages/ImageConversion/trunk/src/filters/imagemagick.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/filters/imagemagick.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -71,9 +71,20 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function scale( $width, $height, $direction =
ezcImageGeometryFilters::SCALE_BOTH )
{
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+
$dirMod = $this->getDirectionModifier( $direction );
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
@@ -95,9 +106,16 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function scaleWidth( $width, $direction )
{
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
+
$dirMod = $this->getDirectionModifier( $direction );
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
@@ -119,9 +137,15 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function scaleHeight( $height, $direction )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
$dirMod = $this->getDirectionModifier( $direction );
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
@@ -140,9 +164,19 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function scalePercent( $width, $height )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+ if ( !is_int( $width ) || $width < 1 || $width > 100 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
'-resize',
@@ -161,9 +195,19 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function scaleExact( $width, $height )
{
+ if ( !is_int( $height ) || $height < 1 )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int > 0' );
+ }
+ if ( !is_int( $width ) || $width < 1 )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int > 0' );
+ }
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
'-resize',
@@ -187,9 +231,28 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function crop( $x, $y, $width, $height )
{
+ if ( !is_int( $x ) || $x < 1 )
+ {
+ throw new ezcBaseValueException( 'x', $x, 'int > 0' );
+ }
+ if ( !is_int( $y ) || $y < 1 )
+ {
+ throw new ezcBaseValueException( 'y', $y, 'int > 0' );
+ }
+ if ( !is_int( $height ) )
+ {
+ throw new ezcBaseValueException( 'height', $height, 'int' );
+ }
+ if ( !is_int( $width ) )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int' );
+ }
+
$xStart = ( $xStart = min( $x, $x + $width ) ) > 0 ? '+'.$xStart :
$xStart;
$yStart = ( $yStart = min( $y, $y + $height ) ) > 0 ? '+'.$yStart :
$yStart;
$this->handler->addFilterOption(
@@ -213,6 +276,9 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference
+ * @throws ezcBaseValueException
+ * If the parameter submitted as the colorspace was not within the
+ * self::COLORSPACE_* constants.
*/
public function colorspace( $space )
{
@@ -251,10 +317,7 @@
break;
return;
default:
- throw new ezcImageFiltersException(
- 'Unknown colorspace.',
- ezcImageFiltersException::INVALID_PARAMETER
- );
+ throw new ezcBaseValueException( 'space', $space,
'self::COLORSPACE_GREY, self::COLORSPACE_SEPIA, self::COLORSPACE_MONOCHROME' );
break;
}
}
@@ -273,9 +336,8 @@
* @param strings $value Noise value as described above.
* @return void
*
- * @throws ezcImageFiltersException
- * If the given noise value is invalid
- * [EMAIL PROTECTED] ezcImageFiltersException::INVALID_PARAMETER}.
+ * @throws ezcBaseValueException
+ * If the noise value is out of range.
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
*/
@@ -292,10 +354,7 @@
);
if ( !in_array( $value, $possibleValues ) )
{
- throw new ezcImageFiltersException(
- 'Unknown noise value <'.$value.'>.',
- ezcImageFiltersException::INVALID_PARAMETER
- );
+ throw new ezcBaseValueException( 'value', $value, 'Uniform,
Gaussian, Multiplicative, Impulse, Laplacian, Poisson' );
}
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
@@ -313,9 +372,15 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcBaseValueException
+ * If the swirl value is out of range.
*/
public function swirl( $value )
{
+ if ( !is_int( $value ) || $value < 0 )
+ {
+ throw new ezcBaseValueException( 'value', $value, 'int >= 0' );
+ }
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
'-swirl',
@@ -342,9 +407,15 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
public function border( $width, array $color )
{
+ if ( !is_int( $width ) )
+ {
+ throw new ezcBaseValueException( 'width', $width, 'int' );
+ }
$colorString = '#';
$i = 0;
foreach ( $color as $id => $colorVal )
@@ -382,6 +453,9 @@
*
* @param int $direction One of ezcImageGeometryFilters::SCALE_*
* @return string The correct modifier.
+ *
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
protected function getDirectionModifier( $direction )
{
@@ -395,9 +469,11 @@
$dirMod = '<';
break;
case self::SCALE_BOTH:
- default:
$dirMod = '';
break;
+ default:
+ throw new ezcBaseValueException( 'direction', $direction,
'self::SCALE_BOTH, self::SCALE_UP, self::SCALE_DOWN' );
+ break;
}
return $dirMod;
}
Modified: packages/ImageConversion/trunk/src/handlers/gd.php
===================================================================
--- packages/ImageConversion/trunk/src/handlers/gd.php 2006-01-13 14:14:40 UTC
(rev 1831)
+++ packages/ImageConversion/trunk/src/handlers/gd.php 2006-01-13 14:31:19 UTC
(rev 1832)
@@ -37,7 +37,7 @@
{
if ( !extension_loaded( 'gd' ) )
{
- throw new ezcImageHandlerNotAvailableException(
'ezcImageGdHandler', 'PHP extension "GD" not available.' );
+ throw new ezcImageHandlerNotAvailableException(
'ezcImageGdHandler', 'PHP extension <GD> not available.' );
}
$this->determineTypes();
parent::__construct( $settings );
@@ -54,9 +54,8 @@
*
* @see ezcImageAnalyzer
*
- * @throws ezcImageHandlerException
- * If the given file does not exist
- * [EMAIL PROTECTED] ezcImageHandlerException::FILE_NOT_EXISTS}.
+ * @throws ezcBaseFileNotFoundException
+ * If the given file does not exist.
* @throws ezcImageMimeTypeUnsupportedException
* If the type of the given file is not recognized
* @throws ezcImageFileNotProcessableException
@@ -87,9 +86,8 @@
*
* @throws ezcImageFileNotProcessableException
* If the given file could not be saved with the given MIME type.
- * @throws ezcImageHandlerException
- * If the desired file exists and is not writeable
- * [EMAIL PROTECTED] ezcImageHandlerException::FILE_NOT_WRITEABLE}.
+ * @throws ezcBaseFilePermissionException
+ * If the desired file exists and is not writeable.
* @throws ezcImageMimeTypeUnsupportedException
* If the desired MIME type is not recognized
*/
Modified: packages/ImageConversion/trunk/src/handlers/imagemagick.php
===================================================================
--- packages/ImageConversion/trunk/src/handlers/imagemagick.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/handlers/imagemagick.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -58,11 +58,8 @@
*
* @see ezcImageAnalyzer
*
- * @throws ezcImageHandlerException
- *
- * @throws ezcImageHandlerException
- * If the desired file does not exist
- * [EMAIL PROTECTED] ezcImageHandlerException::FILE_NOT_EXISTS}.
+ * @throws ezcBaseFileNotFoundException
+ * If the desired file does not exist.
* @throws ezcImageMimeTypeUnsupportedException
* If the desired file has a not recognized type.
*/
@@ -89,9 +86,8 @@
* @param string $mime New MIME type, if differs from initial one.
* @return void
*
- * @throws ezcImageHandlerException
- * If the desired file exists and is not writeable
- * [EMAIL PROTECTED] ezcImageHandlerException::FILE_NOT_WRITEABLE}.
+ * @throws ezcBaseFilePermissionException
+ * If the desired file exists and is not writeable.
* @throws ezcImageMimeTypeUnsupportedException
* If the desired MIME type is not recognized.
*/
Modified: packages/ImageConversion/trunk/src/interfaces/colorspace.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/colorspace.php
2006-01-13 14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/interfaces/colorspace.php
2006-01-13 14:31:19 UTC (rev 1832)
@@ -56,13 +56,12 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
+ * @throws ezcImageFilterFailedException
* If the parameter submitted as the colorspace was not within the
* self::COLORSPACE_* constants
- * [EMAIL PROTECTED] ezcImageFiltersException::INVALID_PARAMETER}.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function colorspace( $space );
}
Modified: packages/ImageConversion/trunk/src/interfaces/effect.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/effect.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/interfaces/effect.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -35,9 +35,10 @@
* @param strings $value Noise value as described above.
* @return void
*
- * @throws ezcImageFiltersException
- * If the given noise value is invalid
- * [EMAIL PROTECTED] ezcImageFiltersException::INVALID_PARAMETER}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
*/
@@ -52,6 +53,10 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function swirl( $value );
@@ -74,6 +79,10 @@
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function border( $width, array $color );
}
Modified: packages/ImageConversion/trunk/src/interfaces/geometry.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/geometry.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/interfaces/geometry.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -68,9 +68,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scale( $width, $height, $direction =
ezcImageGeometryFilters::SCALE_BOTH );
@@ -87,9 +88,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleWidth( $width, $direction );
@@ -106,9 +108,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleHeight( $height, $direction );
@@ -122,9 +125,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scalePercent( $width, $height );
@@ -139,6 +143,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function scaleExact( $width, $height );
@@ -158,9 +166,10 @@
*
* @throws ezcImageInvalidReferenceException
* If no valid resource for the active reference could be found.
- * @throws ezcImageFiltersException
- * If the operation performed by the the filter failed
- * [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
+ * @throws ezcImageFilterFailedException
+ * If the operation performed by the the filter failed.
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
*/
function crop( $x, $y, $width, $height );
}
Modified: packages/ImageConversion/trunk/src/interfaces/handler.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/handler.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/interfaces/handler.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -198,7 +198,7 @@
* If a parameter for the filter is missing.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
- * @throws ezcImageInvalidFilterParameterException
+ * @throws ezcBaseValueException
* If a parameter was not within the expected range.
*/
abstract public function applyFilter( $image, ezcImageFilter $filter );
Modified: packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
2006-01-13 14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
2006-01-13 14:31:19 UTC (rev 1832)
@@ -189,7 +189,7 @@
* If a parameter for the filter is missing.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
- * @throws ezcImageInvalidFilterParameterException
+ * @throws ezcBaseValueException
* If a parameter was not within the expected range.
*/
public function applyFilter( $image, ezcImageFilter $filter )
@@ -261,7 +261,7 @@
$ref = $this->getActiveReference();
if ( ( $resource = $this->getReferenceData( $ref, 'resource' ) ) ===
false )
{
- throw new ezcImageHandlerException( "No resource found for the
active reference <{$ref}>." );
+ throw new ezcImageInvalidReferenceException( "No resource found
for the active reference <{$ref}>." );
}
return $resource;
}
@@ -384,18 +384,14 @@
*
* @throws ezcImageInvalidReferenceException
* If the given reference is invalid.
- * @throws ezcImageHandlerException
+ * @throws ezcBaseValueException
* If the given detail is invalid.
- * [EMAIL PROTECTED] ezcImageHandlerException::INVALID_DETAILS}.
- *
- * @todo Array type hint to replace first check for type of $value!
- * @todo Second check to be replaced by ezcBaseXYZException!
*/
protected function setReferenceData( $reference, $value, $detail = null )
{
if ( !isset( $this->references[$reference] ) )
{
- throw new ezcImageHandlerException( "Invalid image reference
given: <{$reference}>." );
+ throw new ezcImage( "Invalid image reference given:
<{$reference}>." );
}
if ( isset( $detail ) )
{
@@ -405,18 +401,20 @@
{
if ( !is_array( $value ) )
{
- throw new ezcImageHandlerException(
- "Invalid details given for image reference:
<{$reference}>. Details must be stored in an array.",
- ezcImageHandlerException::INVALID_DETAILS
- );
+ throw new ezcBaseValueException( 'value', $value, 'array' );
}
- if ( !isset( $value['file'] ) || !isset( $value['mime'] ) ||
!isset( $value['resource'] ) )
+ if ( !isset( $value['file'] ) )
{
- throw new ezcImageHandlerException(
- "Invalid details given for image reference:
<{$reference}>. Details must contain <file>, <mime> and <resource>.",
- ezcImageHandlerException::INVALID_DETAILS
- );
+ throw new ezcBaseValueException( 'file', null, 'string' );
}
+ if ( !isset( $value['mime'] ) )
+ {
+ throw new ezcBaseValueException( 'mime', null, 'string' );
+ }
+ if ( !isset( $value['resource'] ) )
+ {
+ throw new ezcBaseValueException( 'resource', null, 'string' );
+ }
$this->references[$reference] = $value;
}
}
@@ -434,28 +432,28 @@
* @param string $mime The MIME type of the file.
* @return string reference The reference string for this file.
*
- * @throws ezcImageHandlerException
- * If the desired file does not exist
- * [EMAIL PROTECTED] ezcImageHandlerException::FILE_NOT_EXISTS}.
+ * @throws ezcBaseFileNotFoundException
+ * If the desired file does not exist.
+ * @throws ezcBaseFilePermissionException
+ * If the desired file is not readable.
+ * @throws ezcBaseValueException
+ * If the given detail is invalid.
* @throws ezcImageMimeTypeUnsupportedException
* If the desired file has a not recognized type.
- * @throws ezcImageHandlerException
- * If the given detail is invalid.
- * [EMAIL PROTECTED] ezcImageHandlerException::INVALID_DETAILS}.
*/
protected function loadCommon( $file, $mime = null )
{
$file = realpath( $file );
$ref = md5( $file );
- if ( !is_file( $file ) || !is_readable( $file ) )
+ if ( !is_file( $file ) )
{
- throw new ezcImageHandlerException(
- "Could not read file <{$file}>.",
- ezcImageHandlerException::FILE_NOT_EXISTS
- );
+ throw new ezcBaseFileNotFoundException( $file );
}
-
+ if ( !is_readable( $file ) )
+ {
+ throw new ezcBaseFilePermissionException( $file,
ezcBaseFileException::READ );
+ }
if ( !isset( $mime ) )
{
$mime = '';
@@ -497,9 +495,8 @@
* @param string $mime The new MIME type.
* @return void
*
- * @throws ezcImageHandlerException
- * If the desired file exists and is not writeable
- * [EMAIL PROTECTED]
ezcImageHandlerException::FILE_NOT_PROCESSABLE}.
+ * @throws ezcBaseFilePermissionException
+ * If the desired file is not writeable.
* @throws ezcImageMimeTypeUnsupportedException
* If the desired MIME type is not recognized.
*/
@@ -512,10 +509,7 @@
$file = $this->getReferenceData( $reference, 'file' );
if ( file_exists( $file ) && !is_writeable( $file ) )
{
- throw new ezcImageHandlerException(
- "File is not writeable <{$file}>",
- ezcImageHandlerException::FILE_NOT_PROCESSABLE
- );
+ throw new ezcBaseFilePermissionException( $file,
ezcBaseFileException::WRITE );
}
if ( isset( $mime ) )
@@ -525,7 +519,7 @@
$mime = $this->getReferenceData( $reference, 'mime' );
if ( $this->allowsOutput( $mime ) === false )
{
- throw new ezcImageHandlerException( $mime, 'output' );
+ throw new ezcImageMimeTypeUnsupportedException( $mime, 'output' );
}
}
Modified: packages/ImageConversion/trunk/src/transformation.php
===================================================================
--- packages/ImageConversion/trunk/src/transformation.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/src/transformation.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -105,8 +105,10 @@
* @param array(ezcImageFilter) $filters Filters to apply.
* @param array(string) $mimeOut Output MIME types.
*
- * @throws ezcImageFiltersException On invalid filter or settings error
- * @throws ezcImageHandlerException When the output type is unsupported.
+ * @throws ezcImageFiltersException
+ * On invalid filter or filter settings error.
+ * @throws ezcImageMimeTypeUnsupportedException
+ * If the output type is unsupported.
*/
public function __construct( ezcImageConverter $converter, $name, array
$filters = array(), array $mimeOut = array() )
{
Modified: packages/ImageConversion/trunk/tests/handlergd_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/handlergd_test.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/tests/handlergd_test.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -58,13 +58,8 @@
{
$ref = $this->handler->load( $filePath );
}
- catch ( ezcImageHandlerException $e )
+ catch ( ezcBaseFileNotFoundException $e )
{
- $this->assertEquals(
- ezcImageHandlerException::FILE_NOT_EXISTS,
- $e->getCode(),
- 'Exception with wrong code thrown on not existing file.'
- );
return;
}
$this->fail( 'Required exception not thrown on not existing file.' );
Modified: packages/ImageConversion/trunk/tests/handlershell_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/handlershell_test.php 2006-01-13
14:14:40 UTC (rev 1831)
+++ packages/ImageConversion/trunk/tests/handlershell_test.php 2006-01-13
14:31:19 UTC (rev 1832)
@@ -62,13 +62,8 @@
{
$ref = $this->handler->load( $filePath );
}
- catch ( ezcImageHandlerException $e )
+ catch ( ezcBaseFileNotFoundException $e )
{
- $this->assertEquals(
- ezcImageHandlerException::FILE_NOT_EXISTS,
- $e->getCode(),
- 'Exception with wrong code thrown on not existing file.'
- );
return;
}
$this->fail( 'Required exception not thrown on not existing file.' );
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components