Get the correct PDO binding type for bool data.

@param mixed $value The value being bound.
@param \Cake\Database\Driver $driver The driver.
@return int
163319
public function toStatement($value, Driver $driver)
    {
        if ($value === null) {
            return PDO::PARAM_NULL;
        }

        return PDO::PARAM_BOOL;
    }
155300
public static function getValidTypeFromSample($value) {
        $value = trim((string) $value);

        if (empty($value)) {
            return false;
        }

        foreach (self::$validators as $type => $validator) {
            if ($validator === null) {
                continue;
            }

            if (method_exists(__CLASS__, $validator) && self::$validator($value)) {
                return $type;
            }
        }

        return self::__DEFAULT;
    }
294941
protected function getBoolFromStringInt($value)
    {
        if (!($value == '0' || $value == '1')) {
            $this->throwException(sprintf('Expected "0" or "1" but got: %s', $value));
        }

        return (bool) $value;
    }
663814
protected function checkType($value, $type, $nullable = false)
    {
        if (gettype($value) === $type) {
            return true;
        }
        return $nullable && null === $value;
    }
704643
public function convertToDatabaseValue($value, AbstractPlatform $platform): int
    {
        \assert('is_int($value)');
        if (!isset($this->getValues()[$value])) {
            throw new \InvalidArgumentException('Invalid type.');
        }
        return $value;
    }
552033
protected function typecast($value)
    {
        if ($value === '' && $this->type !== Schema::TYPE_STRING) {
            return null;
        }
        if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) {
            return $value;
        }
        switch ($this->phpType) {
            case 'resource':
            case 'string':
                return is_resource($value) ? $value : (string) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'double':
                return (double) $value;
        }

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

        return serialize($value);
    }
1189592
public static function getType($value)
    {
        if (is_int($value)) {
            return MDataType::INT;
        }

        if (is_long($value)) {
            return MDataType::LONG;
        }

        if (is_bool($value)) {
            return MDataType::BOOLEAN;
        }

        if (is_float($value)) {
            return MDataType::FLOAT;
        }

        if (is_double($value)) {
            return MDataType::DOUBLE;
        }

        if (is_string($value)) {
            return MDataType::STRING;
        }

        if ($value == null) {
            return MDataType::NULL;
        }

        if (is_array($value)) {
            return MDataType::__ARRAY;
        }

        if (is_object($value)) {
            return MDataType::OBJECT;
        }

        if (is_resource($value)) {
            return MDataType::RESOURCE;
        }

        return MDataType::UNKNOWN;
    }
746715
public function bindParam(
        $parameter,
        &$variable,
        $data_type = PDO::PARAM_STR,
        $length = -1,
        $driver_options = null
    )
    {
        if ($driver_options !== null) {
            throw new PDOException('$driver_options is not implemented for PoolPDOStatement::bindParam()');
        }
        if (is_array($variable)) {
            if ($length == -1) {
                $length = count($variable);
            }
        } else {
            if ($length == -1) {
                $length = strlen((string)$variable);
            }
        }
        $this->_boundColumns[$parameter] = $variable;
        return true;
    }
1113923
public function getSqlType($value)
    {
        if ('boolean' === gettype($value)) {
            return $this->connection->getDatabasePlatform()->convertBooleans($value);
        } elseif (null === $value || 'null' === $value) {
            return 'NULL';
        }

        return $this->connection->quote($value);
    }
309192
private function checkType($type, $value)
    {        
        switch($type)
        {
            case 'bool':
            case 'boolean':
                $codeException = (!is_bool($value)) ? 1 : 0;
                break;
            case 'int':
            case 'integer':
                $codeException = (!is_int($value)) ? 1 : 0;
                break;
            case 'string':
                $codeException = (!is_string($value)) ? 1 : 0;
                break;
            case 'not_resource':
                $codeException = (is_resource($value)) ? 2 : 0;
                break;
            default :
                $codeException = 3;
                break;
        }
        
        return $codeException;
    }
1167406
public function getPDOConstantType($value)
    {

        switch (true) {
            case is_int($value):
                $type = PDO::PARAM_INT;
                break;
            case is_bool($value):
                $type = PDO::PARAM_BOOL;
                break;
            case (null === $value):
                $type = PDO::PARAM_NULL;
                break;
            default:
                $type = PDO::PARAM_STR;
        }
        return $type;
    }
1099161
private function getPdoType($value): int
    {
        if (is_int($value) === true) {
            $type = PDO::PARAM_INT;
        } elseif (is_bool($value)) {
            $type = PDO::PARAM_BOOL;
        } elseif ($value instanceof DateTimeInterface) {
            $type = PDO::PARAM_STR;
        } else {
            assert(
                $value !== null,
                'It seems you are trying to use `null` with =, >, <, or etc operator. ' .
                'Use `is null` or `not null` instead.'
            );
            assert(is_string($value), "Only strings, booleans and integers are supported.");
            $type = PDO::PARAM_STR;
        }

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

        return (float)$value;
    }
485665
protected function databaseValue($value)
    {
        if (is_string($value)) {
            return $value;
        }

        if (!$value instanceof BinaryValue) {
            if (!is_resource($value) && !$value instanceof StreamInterface) {
                throw ODMException::invalidValueForType('Binary', ['string', 'resource', 'StreamInterface', 'BinaryValue', 'null'], $value);
            }

            $value = \GuzzleHttp\Psr7\stream_for($value);
        }

        return (string)$value;
    }
1231895
protected function phpTypecastValue($value)
    {
        if ($value === null) {
            return null;
        }

        switch ($this->type) {
            case Schema::TYPE_BOOLEAN:
                switch (strtolower($value)) {
                    case 't':
                    case 'true':
                        return true;
                    case 'f':
                    case 'false':
                        return false;
                }
                return (bool) $value;
            case Schema::TYPE_BIT:
                return bindec($value);
            case Schema::TYPE_BINARY:
                return is_string($value) && strncmp($value, '\\x', 2) === 0 ? pack('H*', substr($value, 2)) : $value;
            case Schema::TYPE_JSON:
                return json_decode($value, true);
            case Schema::TYPE_TIMESTAMP:
            case Schema::TYPE_TIME:
            case Schema::TYPE_DATE:
            case Schema::TYPE_DATETIME:
                return new \DateTime($value);
            case Schema::TYPE_COMPOSITE:
                return $this->phpTypecastComposite($value);
        }

        return $this->typecast($value);
    }
345178
public function matches($value): bool
    {
        if (!interface_exists($this->type) && !class_exists($this->type)) {
            throw new UndefinedTypeException($this->type);
        }

        return $value instanceof $this->type;
    }