Skip to content

Commit

Permalink
temp fix for #93
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdabes committed May 24, 2019
1 parent 1207fae commit 401c06c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Api/Trophy.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,21 @@ public function earnedRate() : float
*/
public function earned() : bool
{
return $this->comparing() ?
$this->trophy->comparedUser->earned :
$this->trophy->fromUser->earned;
// TODO: Temp fix for #93, for some reason the comparedUser isn't always returned from the PlayStation API.
// Needs additional investigation but this will at least stop it bugging out.
if ($this->comparing()) {
if (property_exists($this->trophy, 'comparedUser')) {
return $this->trophy->comparedUser->earned;
}

return false;
}

if (property_exists($this->trophy, 'fromUser')) {
return $this->trophy->fromUser->earned;
}

return false;
}

/**
Expand Down

0 comments on commit 401c06c

Please sign in to comment.