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;
    }