public function materialize(array $data, $entity)
    {
        $key = $this->getColumn()->key();
        $value = null;
        if ($this->isMaterializable($data)) {
            if (!is_null($data[$key])) {
                if ($this->isScalar()) {
                    $value = $data[$key];
                    settype($value, $this->getType());
                } else {
                    $value = AnDomainAttribute::getInstance($this->getType());
                    $value->unserialize($data[$key]);
                }
            }
        } else {
            throw new AnDomainExceptionMapping($this->getName().' Mapping Failed');
        }

        return $value;
    }
public function materialize(array $data, $entity)
    {
        $key = $this->getColumn()->key();
        $value = null;
        if ($this->isMaterializable($data)) {
            if (!is_null($data[$key])) {
                if ($this->isScalar()) {
                    $value = $data[$key];
                    settype($value, $this->getType());
                } else {
                    $value = AnDomainAttribute::getInstance($this->getType());
                    $value->unserialize($data[$key]);
                }
            }
        } else {
            throw new AnDomainExceptionMapping($this->getName().' Mapping Failed');
        }

        return $value;
    }
public function materialize ( array $ data , $ entity ) { $ key = $ this -> getColumn ( ) -> key ( ) ; $ value = null ; if ( $ this -> isMaterializable ( $ data ) ) { if ( ! is_null ( $ data [ $ key ] ) ) { if ( $ this -> isScalar ( ) ) { $ value = $ data [ $ key ] ; settype ( $ value , $ this -> getType ( ) ) ; } else { $ value = AnDomainAttribute :: getInstance ( $ this -> getType ( ) ) ; $ value -> unserialize ( $ data [ $ key ] ) ; } } } else { throw new AnDomainExceptionMapping ( $ this -> getName ( ) . ' Mapping Failed' ) ; } return $ value ; }
Materialize the database value into attribute values for an entity.

@param array                  $data   The raw data of the domain entity
@param AnDomainEntityAbstract $entity Domain entity being fetched

@return string|int|float reutrn a scalar value
Materialize the database value into attribute values for an entity .