public function add($mappingClass)
    {
        try {
            if ($mappingClass instanceof MappingInterface) {
                $mappingClassInstance = $mappingClass;
            } else {
                $reflectionClass = new \ReflectionClass($mappingClass);
                $mappingClassInstance = $reflectionClass->newInstance();
                if (!$mappingClassInstance instanceof MappingInterface) {
                    throw new InvalidMappingClassException('Mapping class must be an instance of MappingInterface');
                }
            }
            self::$container[$mappingClassInstance->getName()] = $mappingClassInstance;
        } catch (\Exception $ex) {
            throw new InvalidMappingClassException($ex->getMessage());
        }
        return $this;
    }
public function add($mappingClass)
    {
        try {
            if ($mappingClass instanceof MappingInterface) {
                $mappingClassInstance = $mappingClass;
            } else {
                $reflectionClass = new \ReflectionClass($mappingClass);
                $mappingClassInstance = $reflectionClass->newInstance();
                if (!$mappingClassInstance instanceof MappingInterface) {
                    throw new InvalidMappingClassException('Mapping class must be an instance of MappingInterface');
                }
            }
            self::$container[$mappingClassInstance->getName()] = $mappingClassInstance;
        } catch (\Exception $ex) {
            throw new InvalidMappingClassException($ex->getMessage());
        }
        return $this;
    }
public function add ( $ mappingClass ) { try { if ( $ mappingClass instanceof MappingInterface ) { $ mappingClassInstance = $ mappingClass ; } else { $ reflectionClass = new \ ReflectionClass ( $ mappingClass ) ; $ mappingClassInstance = $ reflectionClass -> newInstance ( ) ; if ( ! $ mappingClassInstance instanceof MappingInterface ) { throw new InvalidMappingClassException ( 'Mapping class must be an instance of MappingInterface' ) ; } } self :: $ container [ $ mappingClassInstance -> getName ( ) ] = $ mappingClassInstance ; } catch ( \ Exception $ ex ) { throw new InvalidMappingClassException ( $ ex -> getMessage ( ) ) ; } return $ this ; }
Adds new mapping class

@param mixed $mappingClass     Object or full class name is acceptable
@return $this
@throws Exception\InvalidMappingClassException
Adds new mapping class