RSS   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A processData() 0 11 2
1
<?php
2
3
namespace app\models\types;
4
5
use Yii;
6
use app\models\ContentType;
7
8
/**
9
 * This is the model class for RSS content type.
10
 */
11
class RSS extends ContentType
12
{
13
    public $html = '<div class="rss">%data%</div>';
14
    public $input = 'url';
15
    public $output = 'text';
16
    public $usable = false;
17
    public $exemple = null;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function __construct($config = [])
23
    {
24
        parent::__construct($config);
25
        $this->name = Yii::t('app', 'RSS');
26
        $this->description = Yii::t('app', 'Display an RSS feed inline.');
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function processData($data)
33
    {
34
        // Fetch content from cache if possible
35
        $content = self::fromCache($data);
36
        if ($content === false) {
37
            $content = self::downloadContent($data);
38
            self::toCache($data, $content);
39
        }
40
41
        return nl2br(Html::encode($content));
42
    }
43
}
44