From a32044893afbd30b14b794bda0bedbd7e0b2b109 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 2 Aug 2016 14:13:22 +0200 Subject: [PATCH] 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. --- bridges/CADBridge.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index 3405d26..90b338c 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -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);