SimplePieSetUp::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace ejdelmonico\LaravelRSSFeed\helpers;
4
5
use SimplePie;
6
7
/**
8
 * SimplePie SetUp.
9
 */
10
class SimplePieSetUp
11
{
12
    public $feed;
13
14
    /**
15
     * SimplePieSetUp constructor.
16
     */
17
    public function __construct()
18
    {
19
        $this->feed = new SimplePie();
20
    }
21
22
    /**
23
     * Load the config array.
24
     *
25
     * @param array $config
26
     *
27
     * @return \SimplePie
28
     */
29
    public function loadConfig(array $config)
30
    {
31
        $this->feed->set_cache_location($config['cache_location']);
32
        $this->feed->set_cache_duration($config['cache_life']);
33
        $this->feed->enable_cache($config['enable_cache']);
34
        $this->feed->set_item_limit($config['item_limit']);
35
        $this->feed->strip_htmltags($config['strip_htmltags']);
36
        $this->feed->strip_attributes($config['strip_attributes']);
37
        $this->feed->force_feed($config['force_feed']);
38
        $this->feed->enable_order_by_date($config['order_by_date']);
39
        $this->feed->strip_comments($config['strip_comments']);
40
        $this->feed->set_timeout($config['set_timeout']);
41
42
        return $this->feed;
43
    }
44
45
    /**
46
     * Init SimplePie.
47
     */
48
    public function init()
49
    {
50
        $this->feed->init();
51
    }
52
53
    /**
54
     * Set the feed url.
55
     *
56
     * @param $url
57
     */
58
    public function setRSSFeedUrl($url)
59
    {
60
        $this->feed->set_feed_url($url);
61
    }
62
63
    /**
64
     * Wrapper for MIME-types.
65
     */
66
    public function handleContentType()
67
    {
68
        $this->feed->handle_content_type();
69
    }
70
}
71