original_string: 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)
          ));
      }
code: 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)
          ));
      }
code_tokens: 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 ) ) ) ; }
docstring: 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
docstring_tokens: Convert string data into the database format .