protected function _convertFieldsToType(array $fields, $direction)
    {
        if (!in_array($direction, ['toPHP', 'toDatabase'])) {
            throw new InvalidArgumentException(sprintf('Cannot convert type, Cake\Database\Type::%s does not exist', $direction));
        }

        $driver = $this->_table->getConnection()->getDriver();
        foreach ($fields as $field => $content) {
            $column = $this->_table->getSchema()->getColumn($field);
            $type = Type::build($column['type']);

            $fields[$field] = $type->{$direction}($content, $driver);
        }

        return $fields;
    }