Skip to content

Commit

Permalink
Prevent deprecation warnings due to null strings.
Browse files Browse the repository at this point in the history
Fixes #11.
  • Loading branch information
bovender committed Nov 28, 2023
1 parent d17f5b2 commit 64c6fa8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions includes/PubmedParser_Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private function parse( \XMLReader $reader ) {
}
break;
case 'AbstractText':
$label = strip_tags( $reader->getAttribute( 'Label' ) );
$label = strip_tags( $reader->getAttribute( 'Label' ?? '' ) );
$label = trim( preg_replace( '/\s\s+/', ' ', $label ) );
$content = strip_tags( $reader->readInnerXML() );
$content = trim( preg_replace( '/\s\s+/', ' ', $content ) );
Expand Down Expand Up @@ -226,8 +226,10 @@ function journalCaps() {

/// Returns the first page of the article.
function firstPage() {
$fp = explode('-', $this->pages);
return $fp[0];
if ( $this->pages ) {
$fp = explode('-', $this->pages);
return $fp[0];
}
}

function journalAbbrevNoPeriods() {
Expand Down

0 comments on commit 64c6fa8

Please sign in to comment.