From dd1474f1547715cc8450d7ca8464ec5440c838e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 21 Aug 2016 11:46:23 +0200 Subject: [PATCH] [bridges] extract nested functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/ArstechnicaBridge.php | 106 +++++++++++++++++----------------- bridges/DailymotionBridge.php | 25 ++++---- 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/bridges/ArstechnicaBridge.php b/bridges/ArstechnicaBridge.php index 0db9f6fd..c3f72447 100644 --- a/bridges/ArstechnicaBridge.php +++ b/bridges/ArstechnicaBridge.php @@ -3,66 +3,68 @@ #error_reporting(E_ALL); class ArstechnicaBridge extends BridgeAbstract { - public function loadMetadatas() { + public function loadMetadatas() { - $this->maintainer = "prysme"; - $this->name = "ArstechnicaBridge"; - $this->uri = "http://arstechnica.com"; - $this->description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; + $this->maintainer = "prysme"; + $this->name = "ArstechnicaBridge"; + $this->uri = "http://arstechnica.com"; + $this->description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; - } + } - public function collectData(array $param) { - function StripWithDelimiters($string, $start, $end) { - while (strpos($string, $start) !== false) { - $section_to_remove = substr($string, strpos($string, $start)); - $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); - $string = str_replace($section_to_remove, '', $string); - } return $string; - } - function StripCDATA($string) { - $string = str_replace('', '', $string); - return $string; - } + function StripWithDelimiters($string, $start, $end) { + while (strpos($string, $start) !== false) { + $section_to_remove = substr($string, strpos($string, $start)); + $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); + $string = str_replace($section_to_remove, '', $string); + } return $string; + } - function ExtractContent($url) { - #echo $url; - $html2 = getSimpleHTMLDOM($url); + function StripCDATA($string) { + $string = str_replace('', '', $string); + return $string; + } - $text = $html2->find("section[id='article-guts']", 0); + function ExtractContent($url) { + #echo $url; + $html2 = $this->getSimpleHTMLDOM($url); + + $text = $html2->find("section[id='article-guts']", 0); /*foreach ($text->find('