Skip to content

Commit

Permalink
updating parser to use sxe var, removing libxml error checks (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone authored May 3, 2024
1 parent 6e0816d commit da0da8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/LogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ enum LogLevel: string
{
use ValuesTrait;

case EMERGENCY = PLogLevel::EMERGENCY;
case ALERT = PLogLevel::ALERT;
case CRITICAL = PLogLevel::CRITICAL;
case ERROR = PLogLevel::ERROR;
case WARNING = PLogLevel::WARNING;
case NOTICE = PLogLevel::NOTICE;
case INFO = PLogLevel::INFO;
case DEBUG = PLogLevel::DEBUG;
case EMERGENCY = 'emergency';
case ALERT = 'alert';
case CRITICAL = 'critical';
case ERROR = 'error';
case WARNING = 'warning';
case NOTICE = 'notice';
case INFO = 'info';
case DEBUG = 'debug';
}
17 changes: 4 additions & 13 deletions template/core/classes/class_response_parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function getConfig(): <?php echo PHPFHIR_CLASSNAME_CONFIG; ?>
* @param null|string|array|\stdClass|\SimpleXMLElement|\DOMDocument $input
* @return null|\<?php echo ('' === $namespace ? '' : "{$namespace}\\") . PHPFHIR_INTERFACE_TYPE; ?>

* @throws \Exception
*/
public function parse(null|string|array|\stdClass|\SimpleXMLElement|\DOMDocument $input): null|<?php echo PHPFHIR_INTERFACE_TYPE; ?>

Expand Down Expand Up @@ -144,7 +145,6 @@ public function parseSimpleXMLElement(\SimpleXMLElement $input): null|<?php echo

{
$elementName = $input->getName();
$className = <?php echo PHPFHIR_CLASSNAME_TYPEMAP; ?>::getTypeClass($elementName);
/** @var \<?php echo ('' === $namespace ? '' : "{$namespace}\\") . PHPFHIR_INTERFACE_TYPE; ?> $fhirType */
$fhirType = <?php echo PHPFHIR_CLASSNAME_TYPEMAP; ?>::getTypeClass($elementName);
if (null === $fhirType) {
Expand Down Expand Up @@ -189,22 +189,12 @@ public function parseObject(\stdClass|\SimpleXMLElement|\DOMDocument $input): nu
* @param string $input
* @return null|\<?php echo ('' === $namespace ? '' : "{$namespace}\\") . PHPFHIR_INTERFACE_TYPE; ?>

* @throws \Exception
*/
public function parseXml(string $input): null|<?php echo PHPFHIR_INTERFACE_TYPE; ?>

{
libxml_use_internal_errors(true);
$sxe = new \SimpleXMLElement($input, $this->config->getLibxmlOpts();
$err = libxml_get_last_error();
libxml_use_internal_errors(false);
if (false === $err) {
return $this->parseSimpleXMLElement($dom);
}
throw new \DomainException(sprintf(
'Unable to parse provided input as XML. Error: %s; Input: %s',
$err ? $err->message : 'Unknown',
$this->getPrintableStringInput($input)
));
return $this->parseSimpleXMLElement(new \SimpleXMLElement($input, $this->config->getLibxmlOpts()));
}

/**
Expand Down Expand Up @@ -232,6 +222,7 @@ public function parseJson(string $input): null|<?php echo PHPFHIR_INTERFACE_TYPE
* @param string $input
* @return null|\<?php echo ('' === $namespace ? '' : "{$namespace}\\") . PHPFHIR_INTERFACE_TYPE; ?>

* @throws \Exception
*/
public function parseString(string $input): null|<?php echo PHPFHIR_INTERFACE_TYPE; ?>

Expand Down

0 comments on commit da0da8b

Please sign in to comment.