Skip to content

Commit d8b1132

Browse files
author
Nathan
committed
tidy up a few things
1 parent 79654e0 commit d8b1132

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Request/Request.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public function start()
107107
{
108108
while(1)
109109
{
110-
$fp = fsockopen("ssl://stream.twitter.com", 443, $errno, $errstr, 30);
111-
if (!$fp){
112-
echo "ERROR: Twitter Stream Error: failed to open socket";
110+
$fp = fsockopen('ssl://stream.twitter.com', 443, $errno, $errstr, 30);
111+
if(!$fp){
112+
throw new \Exception('Twitter stream failed to open socket');
113113
}else{
114114

115115
fwrite($fp, $this->_buildRequest());
@@ -118,22 +118,21 @@ public function start()
118118

119119
while(!feof($fp))
120120
{
121-
$read = array($fp);
122-
$write = null;
121+
$read = array($fp);
122+
$write = null;
123123
$except = null;
124124

125125
$res = stream_select($read, $write, $except, 600, 0);
126-
if(($res == false) || ($res == 0)){
126+
if($res === false || $res === 0){
127127
break;
128128
}
129129

130130
$json = fgets($fp);
131131

132-
if (strncmp($json, 'HTTP/1.1', 8) == 0){
132+
if(strncmp($json, 'HTTP/1.1', 8) === 0){
133133
$json = trim($json);
134-
if ($json != 'HTTP/1.1 200 OK'){
135-
echo 'ERROR: ' . $json . "\n";
136-
return false;
134+
if ($json !== 'HTTP/1.1 200 OK'){
135+
throw new \Exception('ERROR: ' . $json . "\n";
137136
}
138137
}
139138

@@ -162,11 +161,9 @@ public function start()
162161
}
163162
}
164163
}
165-
166164
fclose($fp);
167165
sleep(10);
168166
}
169-
170167
return;
171168
}
172169
};

0 commit comments

Comments
 (0)