From da8cfdf1798e4fee09288b65bfc015775627875d Mon Sep 17 00:00:00 2001 From: tillcash Date: Sat, 6 Jul 2024 02:09:47 +0530 Subject: [PATCH] [HinduTamilBridge] refactor (#4146) * [HinduTamilBridge] refactor * [HinduTamilBridge] fixed lint * [HinduTamilBridge] fixed lint 2 * Update HinduTamilBridge.php --- bridges/HinduTamilBridge.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/bridges/HinduTamilBridge.php b/bridges/HinduTamilBridge.php index 1b556ed8..d12f5131 100644 --- a/bridges/HinduTamilBridge.php +++ b/bridges/HinduTamilBridge.php @@ -63,18 +63,18 @@ class HinduTamilBridge extends FeedExpander protected function parseItem($item) { $dom = getSimpleHTMLDOMCached($item['uri']); - - $date = $dom->find('p span.date', 1); - if ($date) { - $item['timestamp'] = $this->convertToRFC3339($date->plaintext); - } - $content = $dom->find('#pgContentPrint', 0); - if (!$content) { + + if ($content === null) { return $item; } - $image = $dom->find('#LoadArticle figure', 0); + $date = $dom->find('p span.date', 1); + if ($date) { + $item['timestamp'] = $this->toRFC3339($date->plaintext); + } + + $image = $dom->find('#LoadArticle figure', 0) ?? ''; $item['content'] = $image . $this->cleanContent($content); return $item; @@ -89,15 +89,14 @@ class HinduTamilBridge extends FeedExpander return $content; } - private function convertToRFC3339($DateString) + private function toRFC3339($dateString) { - $timestamp = strtotime(trim($DateString)); + $timestamp = strtotime(trim($dateString)); - if ($timestamp !== false) { - $rfc3339DateTime = date('Y-m-d\TH:i:s', $timestamp) . '+05:30'; - return $rfc3339DateTime; - } else { + if ($timestamp === false) { return null; } + + return date('Y-m-d\TH:i:s', $timestamp) . '+05:30'; } }