Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Finds out whether a variable is a boolean
<?php is_bool(mixed $value): bool
<?php public function validAuthenticationResponse($request, $result)
{
if (is_bool($result)) {
return json_encode($result);
}
<?php foreach ($groupKeys as $groupKey) {
$groupKey = match (true) {
is_bool($groupKey) => (int) $groupKey,
$groupKey instanceof \BackedEnum => $groupKey->value,
$groupKey instanceof \Stringable => (string) $groupKey,
default => $groupKey,
<?php {
$value = $this->get($key, $default);
if (! is_bool($value)) {
throw new InvalidArgumentException(
sprintf('Configuration value for key [%s] must be a boolean, %s given.', $key, gettype($value))
);
<?php protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null)
{
return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite];
}
<?php if ($value instanceof DateTimeInterface) {
$bindings[$key] = $value->format($grammar->getDateFormat());
} elseif (is_bool($value)) {
$bindings[$key] = (int) $value;
}
}
<?php return $this->escapeBinary($value);
} elseif (is_int($value) || is_float($value)) {
return (string) $value;
} elseif (is_bool($value)) {
return $this->escapeBool($value);
} elseif (is_array($value)) {
throw new RuntimeException('The database connection does not support escaping arrays.');
<?php $columns = func_get_args();
if (count($columns) > 0) {
$this->distinct = is_array($columns[0]) || is_bool($columns[0]) ? $columns[0] : $columns;
} else {
$this->distinct = true;
}
<?php if (str_contains($columnString, '->') && is_bool($value)) {
$value = new Expression($value ? 'true' : 'false');
if (is_string($column)) {
<?php protected function compileJsonUpdateColumn($key, $value)
{
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
} elseif (is_array($value)) {
$value = 'cast(? as json)';
<?php public function prepareBindingsForUpdate(array $bindings, array $values)
{
$values = collect($values)->reject(function ($value, $column) {
return $this->isJsonSelector($column) && is_bool($value);
})->map(function ($value) {
return is_array($value) ? json_encode($value) : $value;
})->all();
<?php public function prepareBindingForJsonContains($binding)
{
return is_bool($binding) ? json_encode($binding) : $binding;
}
<?php return "'{$value->value}'";
}
return is_bool($value)
? "'".(int) $value."'"
: "'".(string) $value."'";
}
<?php $sql = sprintf(
' generated %s as identity%s',
$column->always ? 'always' : 'by default',
! is_bool($column->generatedAs) && ! empty($column->generatedAs) ? " ({$column->generatedAs})" : ''
);
}
<?php protected function formatValue($value)
{
return match (true) {
is_bool($value) => sprintf('<fg=#ef8414;options=bold>%s</>', $value ? 'true' : 'false'),
is_null($value) => '<fg=#ef8414;options=bold>null</>',
is_numeric($value) => "<fg=#ef8414;options=bold>{$value}</>",
is_array($value) => '[]',
<?php {
$value = $this->input($key);
return ! is_bool($value) && ! is_array($value) && trim((string) $value) === '';
}