function getValue($entity)
    {
        $raw = $this->property->getValue($entity);

        switch ($this->format)
        {
            case 'scalar':
                return $raw;

            //Serialize classes and arrays before putting them in the DB
            case 'object':
            case 'array':
                return serialize($raw);

            //Json encode before putting into DB
            case 'json':
                return json_encode($raw);

            //Format the date correctly before putting in DB
            case 'date':

                if ($raw)
                {
                    $value = clone $raw;
                    $value->setTimezone(new \DateTimeZone('UTC'));
                    return $value->format('Y-m-d H:i:s');
                }

                else
                {
                    return null;
                }
        }

        return null;
    }
function getValue($entity)
    {
        $raw = $this->property->getValue($entity);

        switch ($this->format)
        {
            case 'scalar':
                return $raw;

            //Serialize classes and arrays before putting them in the DB
            case 'object':
            case 'array':
                return serialize($raw);

            //Json encode before putting into DB
            case 'json':
                return json_encode($raw);

            //Format the date correctly before putting in DB
            case 'date':

                if ($raw)
                {
                    $value = clone $raw;
                    $value->setTimezone(new \DateTimeZone('UTC'));
                    return $value->format('Y-m-d H:i:s');
                }

                else
                {
                    return null;
                }
        }

        return null;
    }
function getValue ( $ entity ) { $ raw = $ this -> property -> getValue ( $ entity ) ; switch ( $ this -> format ) { case 'scalar' : return $ raw ; //Serialize classes and arrays before putting them in the DB case 'object' : case 'array' : return serialize ( $ raw ) ; //Json encode before putting into DB case 'json' : return json_encode ( $ raw ) ; //Format the date correctly before putting in DB case 'date' : if ( $ raw ) { $ value = clone $ raw ; $ value -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; return $ value -> format ( 'Y-m-d H:i:s' ) ; } else { return null ; } } return null ; }
Gets this property's value in the given entity.

@param Relation|Node $entity The entity to get the value from.
@return mixed The property value.
Gets this property s value in the given entity .