protected function castToType($value, $property)
    {
        $type = $this->getPropertyType($property);

        switch ($type) {
            case 'array':
                return is_array($value) ? $value : explode(",", $value);
            case 'bool':
            case 'boolean':
                return (boolean) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'string':
                return (string) $value;
            default:
                return $value;
        }
    }