@@ -21,11 +21,13 @@ discard block |
||
21 | 21 | $max = 0; |
22 | 22 | foreach($this->timers as $timer) |
23 | 23 | { |
24 | - if(!isset($timer['start'])) |
|
25 | - $timer['start'] = PHP_INT_MAX; |
|
24 | + if(!isset($timer['start'])) { |
|
25 | + $timer['start'] = PHP_INT_MAX; |
|
26 | + } |
|
26 | 27 | |
27 | - if(!isset($timer['end'])) |
|
28 | - $timer['end'] = 0; |
|
28 | + if(!isset($timer['end'])) { |
|
29 | + $timer['end'] = 0; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $min = min($timer['start'], $min); |
31 | 33 | $max = max($timer['end'], $max); |
@@ -39,8 +41,9 @@ discard block |
||
39 | 41 | public function renderAscii() |
40 | 42 | { |
41 | 43 | $tpl = ''; |
42 | - foreach($this->timers as $timer) |
|
43 | - $tpl .= $this->tplAscii($timer); |
|
44 | + foreach($this->timers as $timer) { |
|
45 | + $tpl .= $this->tplAscii($timer); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | return $tpl; |
46 | 49 | } |
@@ -49,17 +52,22 @@ discard block |
||
49 | 52 | { |
50 | 53 | $lpad = $rpad = 0; |
51 | 54 | $lspace = $chars = $rspace = ''; |
52 | - if($timer['start'] > $this->min) |
|
53 | - $lpad = intval(($timer['start'] - $this->min) / $this->step); |
|
54 | - if($timer['end'] < $this->max) |
|
55 | - $rpad = intval(($this->max - $timer['end']) / $this->step); |
|
55 | + if($timer['start'] > $this->min) { |
|
56 | + $lpad = intval(($timer['start'] - $this->min) / $this->step); |
|
57 | + } |
|
58 | + if($timer['end'] < $this->max) { |
|
59 | + $rpad = intval(($this->max - $timer['end']) / $this->step); |
|
60 | + } |
|
56 | 61 | $mpad = $this->width - $lpad - $rpad; |
57 | - if($lpad > 0) |
|
58 | - $lspace = str_repeat(' ', $lpad); |
|
59 | - if($mpad > 0) |
|
60 | - $chars = str_repeat('=', $mpad); |
|
61 | - if($rpad > 0) |
|
62 | - $rspace = str_repeat(' ', $rpad); |
|
62 | + if($lpad > 0) { |
|
63 | + $lspace = str_repeat(' ', $lpad); |
|
64 | + } |
|
65 | + if($mpad > 0) { |
|
66 | + $chars = str_repeat('=', $mpad); |
|
67 | + } |
|
68 | + if($rpad > 0) { |
|
69 | + $rspace = str_repeat(' ', $rpad); |
|
70 | + } |
|
63 | 71 | |
64 | 72 | $tpl = <<<TPL |
65 | 73 | ({$timer['api']} :: code={$timer['code']}, start={$timer['start']}, end={$timer['end']}, total={$timer['time']}) |
@@ -1,7 +1,8 @@ |
||
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | -if (php_sapi_name() !== 'cli') |
|
3 | +if (php_sapi_name() !== 'cli') { |
|
4 | 4 | die(); |
5 | +} |
|
5 | 6 | |
6 | 7 | require '../vendor/autoload.php'; |
7 | 8 | $mc = JMathai\PhpMultiCurl\MultiCurl::getInstance(); |
@@ -78,8 +78,7 @@ discard block |
||
78 | 78 | } while ($this->execStatus === CURLM_CALL_MULTI_PERFORM); |
79 | 79 | |
80 | 80 | return new MultiCurlManager($key); |
81 | - } |
|
82 | - else |
|
81 | + } else |
|
83 | 82 | { |
84 | 83 | return $code; |
85 | 84 | } |
@@ -103,8 +102,9 @@ discard block |
||
103 | 102 | |
104 | 103 | // bug in PHP 5.3.18+ where curl_multi_select can return -1 |
105 | 104 | // https://bugs.php.net/bug.php?id=63411 |
106 | - if($ms === -1) |
|
107 | - usleep(100000); |
|
105 | + if($ms === -1) { |
|
106 | + usleep(100000); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | // see pull request https://github.com/jmathai/php-multi-curl/pull/17 |
110 | 110 | // details here http://curl.haxx.se/libcurl/c/libcurl-errors.html |
@@ -173,10 +173,11 @@ discard block |
||
173 | 173 | { |
174 | 174 | $key = $this->getKey($done['handle']); |
175 | 175 | $this->stopTimer($key, $done); |
176 | - if($isAsynchronous) |
|
177 | - $this->responses[$key]['data'] = curl_multi_getcontent($done['handle']); |
|
178 | - else |
|
179 | - $this->responses[$key]['data'] = curl_exec($done['handle']); |
|
176 | + if($isAsynchronous) { |
|
177 | + $this->responses[$key]['data'] = curl_multi_getcontent($done['handle']); |
|
178 | + } else { |
|
179 | + $this->responses[$key]['data'] = curl_exec($done['handle']); |
|
180 | + } |
|
180 | 181 | |
181 | 182 | $this->responses[$key]['response'] = $this->responses[$key]['data']; |
182 | 183 | |
@@ -184,8 +185,9 @@ discard block |
||
184 | 185 | { |
185 | 186 | $this->responses[$key][$name] = curl_getinfo($done['handle'], $const); |
186 | 187 | } |
187 | - if($isAsynchronous) |
|
188 | - curl_multi_remove_handle($this->mc, $done['handle']); |
|
188 | + if($isAsynchronous) { |
|
189 | + curl_multi_remove_handle($this->mc, $done['handle']); |
|
190 | + } |
|
189 | 191 | curl_close($done['handle']); |
190 | 192 | } |
191 | 193 |