SwatDB/SwatDBClassMap.php
public static function add($from_class_name, $to_class_name)
    {
        // check for circular dependency
        if (array_key_exists($to_class_name, self::$map)) {
            $class_name = $to_class_name;
            $child_class_names = array($class_name);
            while (array_key_exists($class_name, self::$map)) {
                $class_name = self::$map[$class_name];
                $child_class_names[] = $class_name;
            }

            if (in_array($from_class_name, $child_class_names)) {
                throw new SwatException(
                    sprintf(
                        'Circular class dependency detected: %s => %s',
                        $from_class_name,
                        implode(' => ', $child_class_names)
                    )
                );
            }
        }

        self::$map[$from_class_name] = $to_class_name;
    }
public static function add($from_class_name, $to_class_name)
    {
        // check for circular dependency
        if (array_key_exists($to_class_name, self::$map)) {
            $class_name = $to_class_name;
            $child_class_names = array($class_name);
            while (array_key_exists($class_name, self::$map)) {
                $class_name = self::$map[$class_name];
                $child_class_names[] = $class_name;
            }

            if (in_array($from_class_name, $child_class_names)) {
                throw new SwatException(
                    sprintf(
                        'Circular class dependency detected: %s => %s',
                        $from_class_name,
                        implode(' => ', $child_class_names)
                    )
                );
            }
        }

        self::$map[$from_class_name] = $to_class_name;
    }
public static function add ( $ from_class_name , $ to_class_name ) { // check for circular dependency if ( array_key_exists ( $ to_class_name , self :: $ map ) ) { $ class_name = $ to_class_name ; $ child_class_names = array ( $ class_name ) ; while ( array_key_exists ( $ class_name , self :: $ map ) ) { $ class_name = self :: $ map [ $ class_name ] ; $ child_class_names [ ] = $ class_name ; } if ( in_array ( $ from_class_name , $ child_class_names ) ) { throw new SwatException ( sprintf ( 'Circular class dependency detected: %s => %s' , $ from_class_name , implode ( ' => ' , $ child_class_names ) ) ) ; } } self :: $ map [ $ from_class_name ] = $ to_class_name ; }
Maps a class name to another class name

Subsequent calls to {@link SwatDBClassMap::get()} using the
<i>$from_class_name</i> will return the <i>$to_class_name</i>. Class
names may be mapped to already mapped class names. For example:

<code>
SwatDBClassMap::add('Object', 'MyObject');
SwatDBClassMap::add('MyObject', 'MyOtherObject');
echo SwatDBClassMap::get('Object'); // MyOtherObject
</code>

If a circular dependency is created, an exception is thrown. If the
<i>$from_class_name</i> is already mapped to another class the old
mapping is overwritten.

@param string $from_class_name the class name to map from.
@param string $to_class_name the class name to map to. The mapped class
must be a subclass of the
<i>$from_class_name</i> otherwise class
resolution using
{@link SwatDBClassMap::get()} will throw
an exception.

@throws SwatException if the added mapping creates a circular dependency.
Maps a class name to another class name