From a84016bcb6790290e8b9963a36a1da54615512f9 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Mon, 29 Aug 2016 19:42:58 +0200 Subject: [PATCH] [core] Rename item getter/setter getDatas -> getItems setDatas -> setItems Note: Bridge->setDatas actually sets data, where Bridge->getItems only returns items (this is why Bridge->setDatas was not changed) --- formats/AtomFormat.php | 2 +- formats/HtmlFormat.php | 2 +- formats/JsonFormat.php | 2 +- formats/MrssFormat.php | 2 +- formats/PlaintextFormat.php | 2 +- index.php | 2 +- lib/Bridge.php | 6 +++--- lib/Format.php | 9 ++++----- lib/RssBridge.php | 2 +- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 991d5be6..e1b88c99 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -19,7 +19,7 @@ class AtomFormat extends FormatAbstract{ $uri = $this->xml_encode($uri); $entries = ''; - foreach($this->getDatas() as $data){ + foreach($this->getItems() as $data){ $entryAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : ''; $entryTitle = isset($data['title']) ? $this->xml_encode($data['title']) : ''; $entryUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : ''; diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php index f2f6e413..4a8f9359 100644 --- a/formats/HtmlFormat.php +++ b/formats/HtmlFormat.php @@ -9,7 +9,7 @@ class HtmlFormat extends FormatAbstract{ $mrssquery = str_replace('format=Html', 'format=Mrss', htmlentities($_SERVER['QUERY_STRING'])); $entries = ''; - foreach($this->getDatas() as $data){ + foreach($this->getItems() as $data){ $entryAuthor = isset($data['author']) ? '

by: ' . $data['author'] . '

' : ''; $entryTitle = isset($data['title']) ? $this->sanitizeHtml(strip_tags($data['title'])) : ''; $entryUri = isset($data['uri']) ? $data['uri'] : $uri; diff --git a/formats/JsonFormat.php b/formats/JsonFormat.php index c1b076ee..261f2250 100644 --- a/formats/JsonFormat.php +++ b/formats/JsonFormat.php @@ -7,7 +7,7 @@ class JsonFormat extends FormatAbstract{ public function stringify(){ // FIXME : sometime content can be null, transform to empty string - $datas = $this->getDatas(); + $datas = $this->getItems(); return json_encode($datas, JSON_PRETTY_PRINT); } diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index 361d64aa..0f707548 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -17,7 +17,7 @@ class MrssFormat extends FormatAbstract{ $uri = $this->xml_encode(!empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/sebsauvage/rss-bridge'); $items = ''; - foreach($this->getDatas() as $data){ + foreach($this->getItems() as $data){ $itemAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : ''; $itemTitle = strip_tags(isset($data['title']) ? $this->xml_encode($data['title']) : ''); $itemUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : ''; diff --git a/formats/PlaintextFormat.php b/formats/PlaintextFormat.php index 7916bc61..059db4c5 100644 --- a/formats/PlaintextFormat.php +++ b/formats/PlaintextFormat.php @@ -6,7 +6,7 @@ class PlaintextFormat extends FormatAbstract{ public function stringify(){ - $datas = $this->getDatas(); + $datas = $this->getItems(); return print_r($datas, true); } diff --git a/index.php b/index.php index 610c19a8..10a13e0b 100644 --- a/index.php +++ b/index.php @@ -137,7 +137,7 @@ try{ try { $format = Format::create($format); $format - ->setDatas($bridge->getDatas()) + ->setItems($bridge->getItems()) ->setExtraInfos(array( 'name' => $bridge->getName(), 'uri' => $bridge->getURI(), diff --git a/lib/Bridge.php b/lib/Bridge.php index c8f5cbac..583598d8 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -139,7 +139,7 @@ abstract class BridgeAbstract implements BridgeInterface { * Return items stored in the bridge * @return mixed */ - public function getDatas(){ + public function getItems(){ return $this->items; } @@ -267,7 +267,7 @@ abstract class BridgeAbstract implements BridgeInterface { $this->collectData(); if(!is_null($this->cache)){ - $this->cache->saveData($this->getDatas()); + $this->cache->saveData($this->getItems()); } return; } @@ -360,7 +360,7 @@ abstract class BridgeAbstract implements BridgeInterface { $this->collectData(); if(!is_null($this->cache)){ - $this->cache->saveData($this->getDatas()); + $this->cache->saveData($this->getItems()); } } diff --git a/lib/Format.php b/lib/Format.php index 486ae849..d01a3cd1 100644 --- a/lib/Format.php +++ b/lib/Format.php @@ -7,7 +7,7 @@ interface FormatInterface{ public function stringify(); public function display(); - public function setDatas(array $bridge); + public function setItems(array $bridges); } abstract class FormatAbstract implements FormatInterface{ @@ -48,15 +48,14 @@ abstract class FormatAbstract implements FormatInterface{ return $this; } - public function setDatas(array $datas){ + public function setItems(array $datas){ $this->datas = $datas; - return $this; } - public function getDatas(){ + public function getItems(){ if( !is_array($this->datas) ){ - throw new \LogicException('Feed the ' . get_class($this) . ' with "setDatas" method before !'); + throw new \LogicException('Feed the ' . get_class($this) . ' with "setItems" method before !'); } return $this->datas; diff --git a/lib/RssBridge.php b/lib/RssBridge.php index 7e175017..4b0aab52 100644 --- a/lib/RssBridge.php +++ b/lib/RssBridge.php @@ -32,7 +32,7 @@ require_once $vendorLibSimpleHtmlDom; Format::setDir(__DIR__ . '/formats/'); $format = Format::create('Atom'); $format - ->setDatas($bridge->getDatas()) + ->setItems($bridge->getItems()) ->setExtraInfos(array( 'name' => $bridge->getName(), 'uri' => $bridge->getURI(),