diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 16:45:36 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 16:45:36 +0200 |
commit | 42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 (patch) | |
tree | 6a17fd7998f291e6dec1d996c1e7c724b92b8e58 /articleenhancer/enhancer.php | |
parent | 0e6598b0734fb927109f745d9c0f3a8605a30ca5 (diff) |
convert tabs indention to indention with 4 spaces because of mixing of both variants in code and better readability on github and websites because you cant set the indention width there and 8 spaces will be used for a tab
Diffstat (limited to 'articleenhancer/enhancer.php')
-rw-r--r-- | articleenhancer/enhancer.php | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/articleenhancer/enhancer.php b/articleenhancer/enhancer.php index e0ad2ab2d..abe8360d2 100644 --- a/articleenhancer/enhancer.php +++ b/articleenhancer/enhancer.php @@ -16,68 +16,68 @@ namespace OCA\News\ArticleEnhancer; class Enhancer { - private $enhancers = []; - private $globalEnhancers = []; - - /** - * @param string $feedUrl - * @param ArticleEnhancer $enhancer - */ - public function registerEnhancer($feedUrl, ArticleEnhancer $enhancer){ - $feedUrl = $this->removeTrailingSlash($feedUrl); - - // create hashkeys for all supported protocols for quick access - $this->enhancers[$feedUrl] = $enhancer; - $this->enhancers['https://' . $feedUrl] = $enhancer; - $this->enhancers['http://' . $feedUrl] = $enhancer; - $this->enhancers['https://www.' . $feedUrl] = $enhancer; - $this->enhancers['http://www.' . $feedUrl] = $enhancer; - } - - - /** - * Registers enhancers that are run for every item and after all previous - * enhancers have been run - * @param ArticleEnhancer $enhancer - */ - public function registerGlobalEnhancer (ArticleEnhancer $enhancer) { - $this->globalEnhancers[] = $enhancer; - } - - - /** - * @param \OCA\News\Db\Item $item - * @param string $feedUrl - * @return \OCA\News\Db\Item enhanced item - */ - public function enhance($item, $feedUrl){ - $feedUrl = $this->removeTrailingSlash($feedUrl); - - if(array_key_exists($feedUrl, $this->enhancers)) { - $result = $this->enhancers[$feedUrl]->enhance($item); - } else { - $result = $item; - } - - foreach ($this->globalEnhancers as $enhancer) { - $result = $enhancer->enhance($result); - } - - return $result; - } + private $enhancers = []; + private $globalEnhancers = []; + + /** + * @param string $feedUrl + * @param ArticleEnhancer $enhancer + */ + public function registerEnhancer($feedUrl, ArticleEnhancer $enhancer){ + $feedUrl = $this->removeTrailingSlash($feedUrl); + + // create hashkeys for all supported protocols for quick access + $this->enhancers[$feedUrl] = $enhancer; + $this->enhancers['https://' . $feedUrl] = $enhancer; + $this->enhancers['http://' . $feedUrl] = $enhancer; + $this->enhancers['https://www.' . $feedUrl] = $enhancer; + $this->enhancers['http://www.' . $feedUrl] = $enhancer; + } + + + /** + * Registers enhancers that are run for every item and after all previous + * enhancers have been run + * @param ArticleEnhancer $enhancer + */ + public function registerGlobalEnhancer (ArticleEnhancer $enhancer) { + $this->globalEnhancers[] = $enhancer; + } + + + /** + * @param \OCA\News\Db\Item $item + * @param string $feedUrl + * @return \OCA\News\Db\Item enhanced item + */ + public function enhance($item, $feedUrl){ + $feedUrl = $this->removeTrailingSlash($feedUrl); + + if(array_key_exists($feedUrl, $this->enhancers)) { + $result = $this->enhancers[$feedUrl]->enhance($item); + } else { + $result = $item; + } + + foreach ($this->globalEnhancers as $enhancer) { + $result = $enhancer->enhance($result); + } + + return $result; + } /** * @param string $url * @return string */ - private function removeTrailingSlash($url) { - if($url[strlen($url)-1] === '/') { - return substr($url, 0, -1); - } else { - return $url; - } - } + private function removeTrailingSlash($url) { + if($url[strlen($url)-1] === '/') { + return substr($url, 0, -1); + } else { + return $url; + } + } }
\ No newline at end of file |