public function toDatabase($value, Driver $driver)
    {
        if ($value === null || is_string($value)) {
            return $value;
        }

        if (is_object($value) && method_exists($value, '__toString')) {
            return $value->__toString();
        }

        if (is_scalar($value)) {
            return (string)$value;
        }

        throw new InvalidArgumentException(sprintf(
            'Cannot convert value of type `%s` to string',
            getTypeName($value)
        ));
    }
public function toDatabase($value, Driver $driver)
    {
        if ($value === null || is_string($value)) {
            return $value;
        }

        if (is_object($value) && method_exists($value, '__toString')) {
            return $value->__toString();
        }

        if (is_scalar($value)) {
            return (string)$value;
        }

        throw new InvalidArgumentException(sprintf(
            'Cannot convert value of type `%s` to string',
            getTypeName($value)
        ));
    }
public function toDatabase ( $ value , Driver $ driver ) { if ( $ value === null || is_string ( $ value ) ) { return $ value ; } if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { return $ value -> __toString ( ) ; } if ( is_scalar ( $ value ) ) { return ( string ) $ value ; } throw new InvalidArgumentException ( sprintf ( 'Cannot convert value of type `%s` to string' , getTypeName ( $ value ) ) ) ; }
Convert string data into the database format.

@param mixed $value The value to convert.
@param \Cake\Database\Driver $driver The driver instance to convert with.
@return string|null
Convert string data into the database format .