00001 <?php
00055 class Object_Freezer_Util
00056 {
00065 public static function readAttributes($object)
00066 {
00067
00068 if (!is_object($object)) {
00069 throw Object_Freezer_Util::getInvalidArgumentException(1, 'object');
00070 }
00071
00072 $reflector = new ReflectionObject($object);
00073 $result = array();
00074
00075
00076 foreach ($reflector->getProperties() as $attribute) {
00077 $attribute->setAccessible(TRUE);
00078 $result[$attribute->getName()] = $attribute->getValue($object);
00079 }
00080
00081 return $result;
00082 }
00083
00091 public static function getInvalidArgumentException($argument, $type)
00092 {
00093 $stack = debug_backtrace(FALSE);
00094
00095 return new InvalidArgumentException(
00096 sprintf(
00097 'Argument #%d of %s:%s() is no %s',
00098 $argument,
00099 $stack[1]['class'],
00100 $stack[1]['function'],
00101 $type
00102 )
00103 );
00104 }
00105 }