Author: Tobias Schlitt
Date: 2006-01-13 11:22:29 +0100 (Fri, 13 Jan 2006)
New Revision: 1815
Log:
- Migrate to new property exceptions.
Modified:
packages/ConsoleTools/trunk/src/output.php
packages/ConsoleTools/trunk/src/progressbar.php
packages/ConsoleTools/trunk/src/statusbar.php
packages/ConsoleTools/trunk/src/structs/output_format.php
packages/ConsoleTools/trunk/src/structs/progressbar_options.php
packages/ConsoleTools/trunk/src/table.php
packages/ConsoleTools/trunk/src/table/cell.php
packages/ConsoleTools/trunk/src/table/row.php
packages/ConsoleTools/trunk/tests/table_cell_test.php
packages/ConsoleTools/trunk/tests/table_test.php
Modified: packages/ConsoleTools/trunk/src/output.php
===================================================================
--- packages/ConsoleTools/trunk/src/output.php 2006-01-13 09:45:56 UTC (rev
1814)
+++ packages/ConsoleTools/trunk/src/output.php 2006-01-13 10:22:29 UTC (rev
1815)
@@ -207,7 +207,7 @@
* @param string $propertyName Name of the property.
* @param mixed $val The value for the property.
*
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a the value for the property options is not an instance of
* ezcConsoleOutputOptions.
* @throws ezcBasePropertyException
@@ -222,22 +222,14 @@
case 'options':
if ( !( $val instanceof ezcConsoleOutputOptions ) )
{
- throw new ezcBasePropertyException(
- 'options',
- 'type:' . is_object( $val ) ? get_class( $val ) :
gettype( $val ),
- 'type:ezcConsoleOutputOptions'
- );
+ throw new ezcBasePropertyException( $key, $val,
'ezcConsoleOutputOptions' );
}
$this->options = $val;
return;
case 'formats':
if ( !( $val instanceof ezcConsoleOutputFormats ) )
{
- throw new ezcBasePropertyException(
- 'format',
- 'type:' . is_object( $val ) ? get_class( $val ) :
gettype( $val ),
- 'type:ezcConsoleOutputFormats'
- );
+ throw new ezcBasePropertyException( $key, $val,
'ezcConsoleOutputFormats' );
}
$this->formats = $val;
return;
Modified: packages/ConsoleTools/trunk/src/progressbar.php
===================================================================
--- packages/ConsoleTools/trunk/src/progressbar.php 2006-01-13 09:45:56 UTC
(rev 1814)
+++ packages/ConsoleTools/trunk/src/progressbar.php 2006-01-13 10:22:29 UTC
(rev 1815)
@@ -176,7 +176,7 @@
*
* @throws ezcBasePropertyNotFoundException
* If a desired property could not be found.
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a desired property value is out of range.
* @return void
*/
@@ -187,22 +187,14 @@
case 'options':
if ( !( $val instanceof ezcConsoleProgressbarOptions ) )
{
- throw new ezcBasePropertyException(
- 'options',
- 'type:' . is_object( $val ) ? get_class( $val ) :
gettype( $val ),
- 'type:ezcConsoleProgressbarOptions'
- );
+ throw new ezcBaseValueException( 'options', $val,
'ezcConsoleProgressbarOptions' );
};
break;
case 'max':
case 'step':
if ( !is_int( $val ) || $val < 0 )
{
- throw new ezcBasePropertyException(
- $key,
- $val,
- 'value >= 0'
- );
+ throw new ezcBasePropertyException( $key, $val, 'int >= 0'
);
}
break;
default:
Modified: packages/ConsoleTools/trunk/src/statusbar.php
===================================================================
--- packages/ConsoleTools/trunk/src/statusbar.php 2006-01-13 09:45:56 UTC
(rev 1814)
+++ packages/ConsoleTools/trunk/src/statusbar.php 2006-01-13 10:22:29 UTC
(rev 1815)
@@ -116,7 +116,7 @@
*
* @throws ezcBasePropertyNotFoundException
* If a desired property could not be found.
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a desired property value is out of range.
* @return void
*/
@@ -128,11 +128,7 @@
case 'failureChar':
if ( strlen( $val ) < 1 )
{
- throw new ezcBasePropertyException(
- $key,
- $val,
- 'length > 1'
- );
+ throw new ezcBasePropertyException( $key, $val, 'string,
not empty' );
}
break;
default:
Modified: packages/ConsoleTools/trunk/src/structs/output_format.php
===================================================================
--- packages/ConsoleTools/trunk/src/structs/output_format.php 2006-01-13
09:45:56 UTC (rev 1814)
+++ packages/ConsoleTools/trunk/src/structs/output_format.php 2006-01-13
10:22:29 UTC (rev 1815)
@@ -70,7 +70,7 @@
*
* @throws ezcBasePropertyNotFoundException
* If the setting you try to access does not exists
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If trying to set an invalid value for a setting.
*
* @param string $propertyName Name of the attrinbute to access.
@@ -93,10 +93,7 @@
{
if ( !ezcConsoleOutput::isValidFormatCode( $propertyName,
$style ) )
{
- throw new ezcBasePropertyException(
- $propertyName,
- $style
- );
+ throw new ezcBaseValueException( $propertyName, $style,
'valid ezcConsoleOutput format code' );
}
}
$this->properties['style'] = $val;
@@ -105,10 +102,7 @@
// Continue normal handling
if ( !ezcConsoleOutput::isValidFormatCode( $propertyName, $val ) )
{
- throw new ezcBasePropertyException(
- $propertyName,
- $val
- );
+ throw new ezcBaseValueException( $propertyName, $style, 'valid
ezcConsoleOutput format code' );
}
$this->properties[$propertyName] = $val;
}
Modified: packages/ConsoleTools/trunk/src/structs/progressbar_options.php
===================================================================
--- packages/ConsoleTools/trunk/src/structs/progressbar_options.php
2006-01-13 09:45:56 UTC (rev 1814)
+++ packages/ConsoleTools/trunk/src/structs/progressbar_options.php
2006-01-13 10:22:29 UTC (rev 1815)
@@ -91,7 +91,7 @@
*
* @throws ezcBasePropertyNotFoundException
* If a desired property could not be found.
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a desired property value is out of range.
*
* @param string $propertyName Name of the property.
@@ -109,13 +109,13 @@
case 'fractionFormat':
if ( strlen( $val ) < 1 )
{
- throw new ezcBasePropertyException( $propertyName, $val,
'value > 0' );
+ throw new ezcBaseValueException( $propertyName, 'string,
not empty', '' );
}
break;
case 'width':
if ( !is_int( $val ) || $val < 5 )
{
- throw new ezcBasePropertyException( $propertyName, $val,
'value > 5' );
+ throw new ezcBaseValueException( $propertyName, 'int >=
5', $val );
}
break;
default:
Modified: packages/ConsoleTools/trunk/src/table/cell.php
===================================================================
--- packages/ConsoleTools/trunk/src/table/cell.php 2006-01-13 09:45:56 UTC
(rev 1814)
+++ packages/ConsoleTools/trunk/src/table/cell.php 2006-01-13 10:22:29 UTC
(rev 1815)
@@ -90,7 +90,7 @@
* @param string $key Name of the property.
* @param mixed $val The value for the property.
*
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a the value submitted for the align is not in the range of
* [EMAIL PROTECTED] ezcConsoleTable::ALIGN_LEFT},
* [EMAIL PROTECTED] ezcConsoleTable::ALIGN_CENTER},
@@ -115,11 +115,7 @@
&& $val !== ezcConsoleTable::ALIGN_DEFAULT
)
{
- throw new ezcBasePropertyException(
- 'align',
- $val,
- 'ezcConsoleTable::ALIGN_DEFAULT,
ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER,
ezcConsoleTable::ALIGN_RIGHT'
- );
+ throw new ezcBaseValueException( $key, $val,
'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT,
ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
}
$this->align = $val;
return;
Modified: packages/ConsoleTools/trunk/src/table/row.php
===================================================================
--- packages/ConsoleTools/trunk/src/table/row.php 2006-01-13 09:45:56 UTC
(rev 1814)
+++ packages/ConsoleTools/trunk/src/table/row.php 2006-01-13 10:22:29 UTC
(rev 1815)
@@ -290,7 +290,7 @@
* @param string $key Name of the property.
* @param mixed $val The value for the property.
*
- * @throws ezcBasePropertyException
+ * @throws ezcBaseValueException
* If a the value submitted for the align is not in the range of
* [EMAIL PROTECTED] ezcConsoleTable::ALIGN_LEFT},
* [EMAIL PROTECTED] ezcConsoleTable::ALIGN_CENTER},
@@ -315,11 +315,7 @@
&& $val !== ezcConsoleTable::ALIGN_DEFAULT
)
{
- throw new ezcBasePropertyException(
- 'align',
- $val,
- 'ezcConsoleTable::ALIGN_DEFAULT,
ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER,
ezcConsoleTable::ALIGN_RIGHT'
- );
+ throw new ezcBaseValueException( $key, $val,
'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT,
ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
}
$this->align = $val;
return;
Modified: packages/ConsoleTools/trunk/src/table.php
===================================================================
--- packages/ConsoleTools/trunk/src/table.php 2006-01-13 09:45:56 UTC (rev
1814)
+++ packages/ConsoleTools/trunk/src/table.php 2006-01-13 10:22:29 UTC (rev
1815)
@@ -390,9 +390,11 @@
*
* @throws ezcBasePropertyNotFoundException
* If a the value for the property options is not an instance of
- * @throws ezcBasePropertyNotFoundException
+ * @throws ezcBaseValueException
* If a the value for a property is out of range.
* @return void
+ *
+ * @todo Remove deprectaed "cols" setting!
*/
public function __set( $key, $val )
{
@@ -401,11 +403,7 @@
case 'options':
if ( !( $val instanceof ezcConsoleTableOptions ) )
{
- throw new ezcBasePropertyException(
- 'options',
- 'type:' . is_object( $val ) ? get_class( $val ) :
gettype( $val ),
- 'type:ezcConsoleTableOptions'
- );
+ throw new ezcBasePropertyException( $key, $val,
'ezcConsoleTableOptions' );
}
$this->options = $val;
return;
@@ -413,7 +411,7 @@
case 'cols':
if ( $val < 1 )
{
- throw new ezcBasePropertyException( $key, $val, 'value >
0' );
+ throw new ezcBaseValueException( $key, $val, 'int > 0' );
}
$this->settings[$key] = $val;
return;
Modified: packages/ConsoleTools/trunk/tests/table_cell_test.php
===================================================================
--- packages/ConsoleTools/trunk/tests/table_cell_test.php 2006-01-13
09:45:56 UTC (rev 1814)
+++ packages/ConsoleTools/trunk/tests/table_cell_test.php 2006-01-13
10:22:29 UTC (rev 1815)
@@ -56,7 +56,7 @@
{
$cell = new ezcConsoleTableCell( 'test', 'success', 42 );
}
- catch ( ezcBasePropertyException $e )
+ catch ( ezcBaseValueException $e )
{
$this->assertTrue(true);
return;
Modified: packages/ConsoleTools/trunk/tests/table_test.php
===================================================================
--- packages/ConsoleTools/trunk/tests/table_test.php 2006-01-13 09:45:56 UTC
(rev 1814)
+++ packages/ConsoleTools/trunk/tests/table_test.php 2006-01-13 10:22:29 UTC
(rev 1815)
@@ -195,7 +195,7 @@
{
$table = new ezcConsoleTable( $this->output, null );
}
- catch (ezcBasePropertyException $e)
+ catch (ezcBaseValueException $e)
{
$this->assertTrue(
true,
@@ -213,7 +213,7 @@
{
$table = new ezcConsoleTable( $this->output, 'test' );
}
- catch (ezcBasePropertyException $e)
+ catch (ezcBaseValueException $e)
{
$this->assertTrue(
true,
@@ -231,7 +231,7 @@
{
$table = new ezcConsoleTable( $this->output, -10 );
}
- catch (ezcBasePropertyException $e)
+ catch (ezcBaseValueException $e)
{
$this->assertTrue(
true,
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components