1
0
Fork 0
forked from blallo/rss-bridge

Replace if-statements with switch statement

The previous implementation would fail if $htmlpart[3] was neither 'cad'
nor 'sillies'. Now the default text will be returned.
This commit is contained in:
logmanoriginal 2016-08-02 14:13:22 +02:00
parent d0c932c149
commit a32044893a

View file

@ -16,10 +16,18 @@ class CADBridge extends BridgeAbstract{
return 'Daily comic not released yet';
$htmlpart = explode("/", $url);
if ($htmlpart[3] == 'cad')
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
if ($htmlpart[3] == 'sillies')
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2);
switch ($htmlpart[3]){
case 'cad':
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
break;
case 'sillies':
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2);
break;
default:
return 'Daily comic not released yet';
}
$img = implode ($url2[0]);
$html3->clear();
unset ($html3);