Completed
Pull Request — master (#7)
by Paweł
07:59
created

HtmlWidget   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 8 2
A isVisible() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Templates System
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\TemplatesSystem\Gimme\Widget;
16
17
use SWP\TemplatesSystem\Gimme\Model\WidgetInterface as ModelWidgetInterface;
18
19
/**
20
 * Widgets idea
21
 * * Every widget have it's own clas with widget implementation
22
 * * Every widget have his own parameters
23
 */
24
25
/**
26
 * Container Interface.
27
 */
28
class HtmlWidget implements WidgetInterface
29
{
30
    protected $widgetModel;
31
32
    public function __construct(ModelWidgetInterface $widgetModel)
33
    {
34
        $this->widgetModel = $widgetModel;
35
    }
36
37
    /**
38
     * Render widget content
39
     *
40
     * @return string
41
     */
42
    public function render()
43
    {
44
        if (array_key_exists('html_body', $this->widgetModel->getParameters())) {
45
            return $this->widgetModel->getParameters()['html_body'];
46
        }
47
48
        return;
49
    }
50
51
    /**
52
     * Check if widget should be rendered
53
     *
54
     * @return boolean
55
     */
56
    public function isVisible()
57
    {
58
        return $this->widgetModel->getVisible();
59
    }
60
}
61