private function fromArray(array $metadata)
    {
        // @TODO Throw exception if mandatory parameters Attribute & Key are missing !!

        $defaults = array('type' => 'mixed', 'mappedClass' => null);
        $data = array_merge($defaults, $metadata);

        $type = $data['type'];
        $mappedClass = $data['mappedClass'];
        $isSupported = isset(static::$supportedTypes[$type]);

        if ($isSupported && 'composite' === static::$supportedTypes[$type]
         && !empty($mappedClass)) {
            // Embedded collection: type => array, mappedClass => FQDN

            if (!static::isValidNamespace($mappedClass)) {
                throw new \InvalidArgumentException(sprintf('Mapped class "%s" is not a valid FQDN', $mappedClass));
            }

            // Set the mapping type & prepend a \ on the mapped FQDN
            $this->mappedType = Definition::COLLECTION;
            $this->mappedClass = (strpos($mappedClass, '\\') === 0) ? $mappedClass : '\\'.$mappedClass;

        } elseif (!$isSupported) {
            // Embedded document: type => FQDN

            if (!static::isValidNamespace($type)) {
                throw new \InvalidArgumentException(sprintf('User type "%s" is not a valid FQDN', $type));
            }

            // Set the mapping type & prepend a \ on the mapped FQDN
            $this->mappedType = Definition::DOCUMENT;
            $this->mappedClass = $type = (strpos($type, '\\') === 0) ? $type : '\\'.$type;
        }

        $this->type = $type;
        $this->attribute = $data['attribute'];
        $this->key = $data['key'];
        $this->accessor = $data['accessor'];
        $this->mutator = $data['mutator'];
    }
private function fromArray(array $metadata)
    {
        // @TODO Throw exception if mandatory parameters Attribute & Key are missing !!

        $defaults = array('type' => 'mixed', 'mappedClass' => null);
        $data = array_merge($defaults, $metadata);

        $type = $data['type'];
        $mappedClass = $data['mappedClass'];
        $isSupported = isset(static::$supportedTypes[$type]);

        if ($isSupported && 'composite' === static::$supportedTypes[$type]
         && !empty($mappedClass)) {
            // Embedded collection: type => array, mappedClass => FQDN

            if (!static::isValidNamespace($mappedClass)) {
                throw new \InvalidArgumentException(sprintf('Mapped class "%s" is not a valid FQDN', $mappedClass));
            }

            // Set the mapping type & prepend a \ on the mapped FQDN
            $this->mappedType = Definition::COLLECTION;
            $this->mappedClass = (strpos($mappedClass, '\\') === 0) ? $mappedClass : '\\'.$mappedClass;

        } elseif (!$isSupported) {
            // Embedded document: type => FQDN

            if (!static::isValidNamespace($type)) {
                throw new \InvalidArgumentException(sprintf('User type "%s" is not a valid FQDN', $type));
            }

            // Set the mapping type & prepend a \ on the mapped FQDN
            $this->mappedType = Definition::DOCUMENT;
            $this->mappedClass = $type = (strpos($type, '\\') === 0) ? $type : '\\'.$type;
        }

        $this->type = $type;
        $this->attribute = $data['attribute'];
        $this->key = $data['key'];
        $this->accessor = $data['accessor'];
        $this->mutator = $data['mutator'];
    }
private function fromArray ( array $ metadata ) { // @TODO Throw exception if mandatory parameters Attribute & Key are missing !! $ defaults = array ( 'type' => 'mixed' , 'mappedClass' => null ) ; $ data = array_merge ( $ defaults , $ metadata ) ; $ type = $ data [ 'type' ] ; $ mappedClass = $ data [ 'mappedClass' ] ; $ isSupported = isset ( static :: $ supportedTypes [ $ type ] ) ; if ( $ isSupported && 'composite' === static :: $ supportedTypes [ $ type ] && ! empty ( $ mappedClass ) ) { // Embedded collection: type => array, mappedClass => FQDN if ( ! static :: isValidNamespace ( $ mappedClass ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Mapped class "%s" is not a valid FQDN' , $ mappedClass ) ) ; } // Set the mapping type & prepend a \ on the mapped FQDN $ this -> mappedType = Definition :: COLLECTION ; $ this -> mappedClass = ( strpos ( $ mappedClass , '\\' ) === 0 ) ? $ mappedClass : '\\' . $ mappedClass ; } elseif ( ! $ isSupported ) { // Embedded document: type => FQDN if ( ! static :: isValidNamespace ( $ type ) ) { throw new \ InvalidArgumentException ( sprintf ( 'User type "%s" is not a valid FQDN' , $ type ) ) ; } // Set the mapping type & prepend a \ on the mapped FQDN $ this -> mappedType = Definition :: DOCUMENT ; $ this -> mappedClass = $ type = ( strpos ( $ type , '\\' ) === 0 ) ? $ type : '\\' . $ type ; } $ this -> type = $ type ; $ this -> attribute = $ data [ 'attribute' ] ; $ this -> key = $ data [ 'key' ] ; $ this -> accessor = $ data [ 'accessor' ] ; $ this -> mutator = $ data [ 'mutator' ] ; }
Import an array of metadata

@param array $metadata

@return void
Import an array of metadata