original_string: public function toDatabase($value, Driver $driver)
      {
          if ($value === true || $value === false || $value === null) {
              return $value;
          }
  
          if (in_array($value, [1, 0, '1', '0'], true)) {
              return (bool)$value;
          }
  
          throw new InvalidArgumentException(sprintf(
              'Cannot convert value of type `%s` to bool',
              getTypeName($value)
          ));
      }
code: public function toDatabase($value, Driver $driver)
      {
          if ($value === true || $value === false || $value === null) {
              return $value;
          }
  
          if (in_array($value, [1, 0, '1', '0'], true)) {
              return (bool)$value;
          }
  
          throw new InvalidArgumentException(sprintf(
              'Cannot convert value of type `%s` to bool',
              getTypeName($value)
          ));
      }
code_tokens: public function toDatabase ( $ value , Driver $ driver ) { if ( $ value === true || $ value === false || $ value === null ) { return $ value ; } if ( in_array ( $ value , [ 1 , 0 , '1' , '0' ] , true ) ) { return ( bool ) $ value ; } throw new InvalidArgumentException ( sprintf ( 'Cannot convert value of type `%s` to bool' , getTypeName ( $ value ) ) ) ; }
docstring: Convert bool data into the database format.
  
  @param mixed $value The value to convert.
  @param \Cake\Database\Driver $driver The driver instance to convert with.
  @return bool|null
docstring_tokens: Convert bool data into the database format .