function setValue($entity, $value)
    {
        switch ($this->format)
        {
            case 'scalar':
                $this->property->setValue($entity, $value);
                break;

            //Unserialize classes and arrays before putting them back in the entity.
            case 'object':
            case 'array':
                $this->property->setValue($entity, unserialize($value));
                break;

            //Decode Json from DB back into a regular assoc array before putting it into the entity.
            case 'json':
                $this->property->setValue($entity, json_decode($value, true));
                break;

            //Create a date time object out of the db stored date before putting it into the entity.
            case 'date':
                $date = null;
                if ($value) {
                    $date = new \DateTime($value . ' UTC');
                    $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                }

                $this->property->setValue($entity, $date);
                break;
        }
    }