Convert a human-readable string values to boolean value.

@param string $value
The human-readable string value to convert to boolean value.

@return bool Boolean value for the given variable.
431178
public static function toBooleanValue(string $value): bool
    {
        if (empty($value)) {
            return false;
        }
        
        return !in_array(strtolower(trim($value)), StringUtils::FALSES);
    }
873024
public static function isStringable($value)
    {
        return static::isStringLike($value) || is_numeric($value) || is_bool($value) || is_null($value);
    }
1340187
private static function getConvertedXmlValue($value)
    {
        $value = (string) $value; // convert from simplexml to string
        // handle booleans specially
        $lwr = strtolower($value);
        if ($lwr === "false") {
            $value = false;
        } elseif ($lwr === "true") {
            $value = true;
        }

        return $value;
    }
948503
public function parseBooleanValue($value)
    {
        if (is_bool($value)) {
            return $value;
        }
        switch (strtolower($value)) {
            case 'true':
                return true;
            case 'false':
                return false;
        }

        throw new RuntimeException("Unknown boolean value '{$value}'.");
    }
267449
protected function normalizeBoolean($value)
    {
        switch (true) {
            case $this->checkFlag(self::BOOLEAN_MODE_INTEGER):
            default:
                return (int) $value;

                break;

            case $this->checkFlag(self::BOOLEAN_MODE_BOOL_STRING):
                return $value === true ? 'true' : 'false';

                break;

            case $this->checkFlag(self::BOOLEAN_MODE_STRING):
                return $value === true ? 'On' : 'Off';

                break;
        }
    }
1060855
public function getBooleanValue($value)
    {
        if ($value === null) {
            return;
        }

        if ($this->listData) {
            reset($this->listData);
            list(, $yes_value) = @each($this->listData);
            list(, $no_value) = @each($this->listData);
            if ($no_value === null) {
                $no_value = '';
            }
            /* not to convert N to Y */
            if ($yes_value == $value) {
                return $yes_value;
            }
            if ($no_value == $value) {
                return $no_value;
            }
        } else {
            $yes_value = 1;
            $no_value = 0;
        }

        return $value ? $yes_value : $no_value;
    }
88742
public function isAssignableFromValue($value)
    {
        switch ($this->name)
        {
            case self::INTEGER_NAME:
                return is_int($value);
            case self::FLOAT_NAME:
                return is_float($value);
            case self::STRING_NAME:
                return is_string($value);
            case self::BOOLEAN_NAME:
                return is_bool($value);
            case self::MIXED_NAME:
                return true;
            case self::RESOURCE_NAME:
                return is_resource($value);
            case self::OBJECT_NAME:
                return is_object($value);
            case self::NULL_NAME:
                return is_null($value);
            case self::CALLABLE_NAME:
                return is_callable($value);
            default:
                throw new Exception("Implementation error");
        }
    }
1338494
protected function getBoolFromStringBool($value)
    {
        if (!($value == 'true' || $value == 'false')) {
            $this->throwException(sprintf('Expected "true" or "false" but got %s', $value));
        }

        return $value === 'true' ? true : false;
    }
1035037
protected function getStringValue($value)
    {
        if ($value === true) {
            return 'true';
        } elseif ($value === false) {
            return 'false';
        } elseif ($value === null) {
            return 'null';
        } elseif (is_string($value)) {
            return "\"$value\"";
        }

        return rtrim(print_r($value, true));
    }
962231
protected function valueBool($value)
	{
		if ($value !== false && empty($value)) return Yii::$app->formatter->nullDisplay;
		return Yii::$app->formatter->asBoolean($value);
	}
486958
protected function _validate_bool($value)
    {
        $trueValues = ['1', 'true'];
        $falseValues = ['0', 'false'];

        if (in_array($value, $trueValues, true)) {
            return true;
        } elseif (in_array($value, $falseValues, true)) {
            return false;
        } else {
            return null;
        }
    }
1046313
public function setValue($value)
    {
        // special case for boolean values
        if (is_bool($value)) {
            if ($value) {
                $this->_value = "true";
            } else {
                $this->_value = "false";
            }
        } else {
            $this->_value = (string) $value;
        }
    }
252954
public static function url(string $value): bool
    {
        $result = filter_var($value, FILTER_VALIDATE_URL);
        return is_string($result) && $value === $result;
    }
1151782
public static function toBool($value)
    {
        if ($value instanceof Countable) {
            return (bool)count($value);
        }

        if (!static::isStringLike($value)) {
            return (bool)$value;
        }

        $string = "$value";

        if (trim($string) == '') {
            return false;
        }

        if (in_array(strtolower($value), ['0', 'false'], true)) {
            return false;
        }

        return (bool)$string;

    }
393116
private function boolishToFlag($value): bool
    {
        switch (true) {
            case 'true' === $value:
            case true === $value:
            case 'yes' === $value:
                return true;
            case 'no' === $value:
            case 'false' === $value:
            case false === $value:
                return false;
            default:
                throw new \InvalidArgumentException('Invalid value for remove-obsolete flag.');
        }
    }
29701
static private function stringify($value)
        {
            if (is_bool($value)) {
                return $value ? '<TRUE>' : '<FALSE>';
            }

            if (is_scalar($value)) {
                $val = (string) $value;

                if (strlen($val) > 100) {
                    $val = substr($val, 0, 97) . '...';
                }

                return $val;
            }

            if (Arrays::is($value)) {
                return '<ARRAY>';
            }

            if (is_object($value)) {
                return get_class($value);
            }

            if (is_resource($value)) {
                return '<RESOURCE>';
            }

            if ($value === null) {
                return '<NULL>';
            }

            return 'unknown';
        }
422372
public static function trueFalse($value)
    {
        if ((is_numeric($value) && $value > 0) || strtoupper($value) == 'Y') {
            return 1;
        }

        return filter_var($value, FILTER_VALIDATE_BOOLEAN) ? 1 : 0;
    }