Skip to content
Snippets Groups Projects
Commit 0dc62f4b authored by Beatrycze Volk's avatar Beatrycze Volk
Browse files

Check for array before passing to foreach loop

parent d0b27125
No related branches found
No related tags found
No related merge requests found
...@@ -89,16 +89,22 @@ class Score ...@@ -89,16 +89,22 @@ class Score
*/ */
public function __construct($score) public function __construct($score)
{ {
foreach ($score->title as $title) { if (is_array($score->title) || is_object($score->title)) {
$this->titleArticles[] = new Article($title); foreach ($score->title as $title) {
$this->titleArticles[] = new Article($title);
}
} }
foreach ($score->abstract as $abstract) { if (is_array($score->abstract) || is_object($score->abstract)) {
$this->abstractArticles[] = new Article($abstract); foreach ($score->abstract as $abstract) {
$this->abstractArticles[] = new Article($abstract);
}
} }
foreach ($score->dois as $doi) { if (is_array($score->dois) || is_object($score->dois)) {
$this->referenceArticles[] = new Article($doi); foreach ($score->dois as $doi) {
$this->referenceArticles[] = new Article($doi);
}
} }
$this->semanticScore = $score->semantic_score; $this->semanticScore = $score->semantic_score;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment