miarau /
rssfeed
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * A factory wrapper for creating objects of external RSS libs. |
||
| 4 | * |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace Miax\RSSFeed; |
||
| 8 | use SimplePie; |
||
| 9 | |||
| 10 | define('CACHE', __DIR__.'/../../webroot/cache/'); |
||
| 11 | require_once(__DIR__."/simplepie/simplepie_1.3.1.mini.php"); |
||
| 12 | |||
| 13 | class CRSSFeed { |
||
| 14 | |||
| 15 | // constructor - initialize SimplePie. |
||
| 16 | public function __construct($feedArr, $duration = 3600) { |
||
| 17 | $this->object = new SimplePie(); |
||
| 18 | $this->object->set_cache_location(CACHE); |
||
| 19 | $this->object->set_cache_duration($duration); |
||
| 20 | $this->object->set_feed_url($feedArr); |
||
| 21 | $this->object->init(); |
||
| 22 | } |
||
| 23 | |||
| 24 | // return content. |
||
| 25 | public function getFeed() { |
||
| 26 | $feedItems = $this->object->get_items(); |
||
| 27 | $html = '<article>'; |
||
| 28 | $html .= "<h1>Senaste nytt fran IDG</h1>"; |
||
| 29 | foreach($feedItems as $content) { |
||
| 30 | $html .= '<div class="feed-content">'; |
||
| 31 | $html .= "<h2>" . $content->get_title() . "</h2>" ; |
||
| 32 | $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
||
| 33 | $html .= "<p>{$content->get_content()}</p>"; |
||
| 34 | $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
||
| 35 | $html .= '</div>'; |
||
| 36 | } |
||
| 37 | $html .= "</article>"; |
||
| 38 | return $html; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /*$rss = new SimplePie(); |
||
|
0 ignored issues
–
show
|
|||
| 43 | $rss->get_items(1,1); |
||
| 44 | $feed = new CRSSFeed($rss); |
||
| 45 | if ($feed->getFeed()){ |
||
| 46 | print "OK"; |
||
| 47 | } |
||
| 48 | */ |
||
| 49 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.