src/Parser.php
public static function getPhpValue($val, $default = null, ParserInterface $parser = null)
    {
        if ($val instanceof DOMElement) {
            $parser = $parser ?: new static;

            return $parser->parseDomElement($val);
        }

        if (0 === strlen($val)) {
            return $default;
        }

        if (0 === strpos($val, '0x') && preg_match('#^[[:xdigit:]]+$#', substr($val, 2))) {
            return hexdec($val);
        }

        if (is_numeric($val)) {
            return ctype_digit($val) ? intval($val) : floatval($val);
        }

        if (in_array($lval = strtolower($val), ['true', 'false'])) {
            return $lval === 'true' ? true : false;
        }

        return $val;
    }
public static function getPhpValue($val, $default = null, ParserInterface $parser = null)
    {
        if ($val instanceof DOMElement) {
            $parser = $parser ?: new static;

            return $parser->parseDomElement($val);
        }

        if (0 === strlen($val)) {
            return $default;
        }

        if (0 === strpos($val, '0x') && preg_match('#^[[:xdigit:]]+$#', substr($val, 2))) {
            return hexdec($val);
        }

        if (is_numeric($val)) {
            return ctype_digit($val) ? intval($val) : floatval($val);
        }

        if (in_array($lval = strtolower($val), ['true', 'false'])) {
            return $lval === 'true' ? true : false;
        }

        return $val;
    }
public static function getPhpValue ( $ val , $ default = null , ParserInterface $ parser = null ) { if ( $ val instanceof DOMElement ) { $ parser = $ parser ? : new static ; return $ parser -> parseDomElement ( $ val ) ; } if ( 0 === strlen ( $ val ) ) { return $ default ; } if ( 0 === strpos ( $ val , '0x' ) && preg_match ( '#^[[:xdigit:]]+$#' , substr ( $ val , 2 ) ) ) { return hexdec ( $ val ) ; } if ( is_numeric ( $ val ) ) { return ctype_digit ( $ val ) ? intval ( $ val ) : floatval ( $ val ) ; } if ( in_array ( $ lval = strtolower ( $ val ) , [ 'true' , 'false' ] ) ) { return $ lval === 'true' ? true : false ; } return $ val ; }
Get the php equivalent of an input value derived from any king of xml.

@param mixed $val
@param mixed $default
@param ParserInterface $parser

@return mixed
Get the php equivalent of an input value derived from any king of xml .