Process XML value, handling boolean, if appropriate.
@param  \SimpleXMLElement $value The simplexml value object.
@return mixed             string or boolean value
165192
private static function getConvertedXmlValue($value)
    {
        $value = (string) $value; // convert from simplexml to string

        //handle numeric values
        if (is_numeric($value)) {
            if (ctype_digit($value)) {
                $value = intval($value);
            } else {
                $value = floatval($value);
            }
        }

        // handle booleans specially
        $lwr = strtolower($value);
        if ($lwr === "false") {
            return false;
        }
        if ($lwr === "true") {
            return true;
        }

        return $value;
    }
568546
public static function convertFromXML($value)
    {
        $converted = strip_tags($value);
        if (!$converted || $converted === $value) {
            return $value;
        } else {
            return $value . "\n" . $converted;
        }
    }
30759
private static function bool2str($value){
        //convert boolean to text value.
        $value = $value === true ? 'true' : $value;
        $value = $value === false ? 'false' : $value;
        return $value;
    }
787464
public static function phpToXml($value)
    {
        switch (true) {
            case null === $value:
                return 'null';
            case true === $value:
                return 'true';
            case false === $value:
                return 'false';
            case $value instanceof Parameter:
                return '%'.$value.'%';
            case is_object($value) || is_resource($value):
                throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
            default:
                return (string) $value;
        }
    }
102092
public function is($value)
    {
        if ($value === null) {
            return $this->isNull();
        }

        if (\is_array($value)) {
            return $this->in($value);
        }

        $this->predicates[] = $this->processValue($value);

        return $this;
    }
159800
public static function isBooleanValue(string $value): bool
    {
        return in_array(strtolower(trim($value)), StringUtils::TRUES) || in_array(strtolower(trim($value)), StringUtils::FALSES);
    }
1206284
public function encode($value)
    {
        switch (true) {
            case is_null($value):
                return $this->encodeString('', self::T_NULL);
            case is_bool($value):
                return $this->encodeString($value ? 'true' : 'false', self::T_BOOL);
            case is_int($value):
                return $this->encodeString($value, self::T_INT);
            case is_float($value):
                return $this->encodeString($value, self::T_FLOAT);
            case is_array($value):
                return $this->encodePHPArray($value);

            case is_resource($value):
                throw new InvalidArgumentException("You can't encode a PHP resource as a tagged netstring.");

            default:
                return $this->encodeString($value);
        }
    }
651379
public function setXML($value = FALSE)
    {
        if (!$value) {
            $this->isXML = FALSE;
        } else {
            $this->isXML = TRUE;
        }
    }
283749
public function validate($value)
    {
        if (!$value instanceof DOMDocument) {
            $this->errors[] = TypeValidationError::xmlValidationFailed('Expected value of type DOMDocument');

            return;
        }

        $originalErrorLevel = \libxml_use_internal_errors(true);
        $value->schemaValidateSource($this->xml);
        $errors = \libxml_get_errors();
        \libxml_clear_errors();
        if ($errors) {
            foreach ($errors as $error) {
                $this->errors[] = TypeValidationError::xmlValidationFailed($error->message);
            }

            return;
        }

        \libxml_use_internal_errors($originalErrorLevel);
    }
405179
public function transform($value)
    {
        if ($value === null) {
            return $value;
        }

        $realValue = strtolower(trim($value));
        if ( ! array_key_exists($realValue, $this->conversions)) {
            throw new LogicException("A boolean value must be provided (`0` or `false`, `1` or `true`).");
        }

        return $this->conversions[$realValue];
    }
1260366
private static function encodeValueXml($value)
    {
        if ($value instanceof \DateTime) {
            return $value->format('Y-m-d\TH:i:s.000\Z');
        }
        else if (is_bool($value)){
            return $value ? 'true' : 'false';
        } else {
            return $value;
        }
    }
1217163
public function createAttributeValue($value)
    {
        $v = new BooleanValue();
        $value = ($value == false || $value == '0') ? false : true;
        $v->setValue($value);

        return $v;
    }
1175183
public function transform($value)
    {
        if (!$value instanceof Value) {
            return '';
        }

        return $this->docbookToXhtml5EditConverter->convert($value->xml)->saveXML();
    }
870760
public static function bool($value=false, bool $flatten=false) {
		ref\cast::bool($value, $flatten);
		return $value;
	}
12379
protected function processValue(&$value) {
    if (!is_array($value)) {
      // decode encoded (%##) values
      if (preg_match ("/%/", $value)) {
        $value = urldecode($value);
      }
      // make arrays
      if(preg_match("/^{.*}$/", $value)) {
        $arrayValues = StringUtil::quotesplit(substr($value, 1, -1));
        $value = [];
        foreach ($arrayValues as $arrayValue) {
          $value[] = trim($arrayValue);
        }
      }
    }
  }
871656
public function process($value)
        {

            if ($this->isMandatory() && !$value)
            {
                throw new Exception($this->getMessage(self::IS_MISSING, ['param', $this->reference]));
            }

            $dataProcessor = $this->getDataProcessor();

            if ($dataProcessor instanceof ApplicationAwareInterface)
            {
                $dataProcessor->setApplication($this->getApplication());
            }

            $processedValue = $dataProcessor->process($value);

            if($this->isMandatory() && is_null($processedValue))
            {
                throw new Exception($this->getMessage(self::IS_MISSING, ['param', $this->reference]));
            }

            return $processedValue;
        }
920505
protected function _value($value)
    {
        if ($value === null) {
            return 'null';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }

        return (string)$value;
    }