00001 <?php 00002 /*************************************************************************** 00003 * Copyright (C) 2006-2007 by Konstantin V. Arkhipov * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Lesser General Public License as * 00007 * published by the Free Software Foundation; either version 3 of the * 00008 * License, or (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 /* $Id: IdentifiablePrimitive.class.php 4687 2007-12-09 18:57:18Z voxus $ */ 00012 00016 abstract class IdentifiablePrimitive extends PrimitiveInteger 00017 { 00018 protected $className = null; 00019 00020 abstract public function of($className); 00021 00026 public function setValue($value) 00027 { 00028 $className = $this->className; 00029 00030 Assert::isTrue($value instanceof $className); 00031 00032 return parent::setValue($value); 00033 } 00034 00035 protected static function guessClassName($class) 00036 { 00037 if (is_string($class)) 00038 return $class; 00039 elseif (is_object($class)) { 00040 if ($class instanceof Identifiable) 00041 return get_class($class); 00042 elseif ($class instanceof GenericDAO) 00043 return $class->getObjectName(); 00044 } 00045 00046 throw new WrongArgumentException('strange class given - '.$class); 00047 } 00048 } 00049 ?>