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)
        ));
    }
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)
        ));
    }
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 ) ) ) ; }
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
Convert bool data into the database format .