Skip to content

Commit e19aef7

Browse files
author
Melroy van den Berg
committed
Change API response variable to local variable
1 parent 34fce30 commit e19aef7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
include 'metacritic.php';
55

66
$metacritic_api = new MetacriticAPI();
7-
$response = $metacritic_api->get_metacritic_page("The Elder Scrolls V: Skyrim");
8-
$json_reponse = $metacritic_api->get_metacritic_scores($response);
7+
$metacritic_api->get_metacritic_page("The Elder Scrolls V: Skyrim");
8+
$json_reponse = $metacritic_api->get_metacritic_scores();
99

1010
echo "Json Output:\n<br/><br/> ". $json_reponse;
1111
?>

metacritic.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
class MetacriticAPI
66
{
7+
private $response_body = "";
8+
9+
function __construct() {
10+
}
11+
712
public function get_metacritic_page($game_name)
813
{
914
$returnValue = "";
@@ -22,13 +27,13 @@ public function get_metacritic_page($game_name)
2227
{
2328
$returnValue = $response->raw_body;
2429
}
25-
return $returnValue;
30+
$this->response_body = $returnValue;
2631
}
2732

28-
public function get_metacritic_scores($page_response)
33+
public function get_metacritic_scores()
2934
{
3035
# Get DOM by string content
31-
$html = str_get_html($page_response);
36+
$html = str_get_html($this->response_body);
3237
# Define json output array
3338
$json_output = array();
3439
$error = false;

0 commit comments

Comments
 (0)