File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,14 @@ protected function setUpXml(array $arguments = [])
133133
134134 // Pass the results back
135135 return simplexml_load_file ($ steamUrl . '? ' . $ parameters );
136+ libxml_use_internal_errors (true );
137+ $ result = simplexml_load_file ($ steamUrl . '? ' . $ parameters );
138+
139+ if (! $ result ) {
140+ return null ;
141+ }
142+
143+ return $ result ;
136144 }
137145
138146 public function getRedirectUrl ()
Original file line number Diff line number Diff line change @@ -84,13 +84,17 @@ public function GetPlayerAchievements($appId)
8484 if (is_int ($ appId )) {
8585 $ this ->getRedirectUrl ();
8686
87- // Get the client
88- $ client = $ this ->setUpXml ($ arguments );
87+ try {
88+ // Get the client
89+ $ client = $ this ->setUpXml ($ arguments );
8990
90- // Clean up the games
91- $ achievements = $ this ->convertToObjects ($ client ->achievements ->achievement );
91+ // Clean up the games
92+ $ achievements = $ this ->convertToObjects ($ client ->achievements ->achievement );
9293
93- return $ achievements ;
94+ return $ achievements ;
95+ } catch (\Exception $ exception ) {
96+ return null ;
97+ }
9498 }
9599
96100 // If the name and ID fail, return null.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class UserStatsTest extends BaseTester {
66 /** @test */
77 public function it_returns_null_when_there_are_no_achievements_for_a_game ()
88 {
9- $ achievements = $ this ->steamClient ->userStats ($ this ->id64 )->GetPlayerAchievements (42690 );
9+ $ achievements = $ this ->steamClient ->userStats ($ this ->id64 )->GetPlayerAchievements (359320 );
1010
1111 $ this ->assertNull ($ achievements );
1212 }
You can’t perform that action at this time.
0 commit comments