Plugin   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
C renderInternal() 0 40 11
1
<?php
2
/**
3
 * Render a plugin
4
 *
5
 * @author  Tim Lochmüller
6
 */
7
8
namespace FRUIT\Ink\Rendering;
9
10
/**
11
 * Render a plugin
12
 */
13
class Plugin extends AbstractRendering
14
{
15
16
    /**
17
     * Render the given element
18
     *
19
     * @return array
20
     */
21
    public function renderInternal()
22
    {
23
        $lines = array();
24
        $lines[] = 'Test';
25
        $myName = false;
26
        $listType = $this->contentObject->data['list_type'];
27
        $template = $GLOBALS['TSFE']->tmpl;
28
29
        if (isset($template->setup['tt_content.']['list.']['20.'][$listType])) {
30
            $theValue = $template->setup['tt_content.']['list.']['20.'][$listType];
31
            $theConf = $template->setup['tt_content.']['list.']['20.'][$listType . '.'];
32
        } else {
33
            $tmp = explode('_pi', $listType);
34
            if (count($tmp) < 2) {
35
                $myName = 'tx_' . str_replace('_', '', $tmp[0]);
36
            } else {
37
                $myName = 'tx_' . str_replace('_', '', $tmp[0]) . '_pi' . $tmp[1];
38
            }
39
            $theValue = $template->setup['plugin.'][$myName];
40
            $theConf = $template->setup['plugin.'][$myName . '.'];
41
        }
42
        $content = $this->contentObject->cObjGetSingle($theValue, $theConf);
43
44
        $myContent = $this->breakContent(strip_tags($content));
45
        if (strlen($myContent) > 1) {
46
            if (substr($myContent, 0, 1) == '|' && substr($myContent, -1) == '|') {
47
                $myContent = substr($myContent, 1, strlen($myContent) - 2);
48
            }
49
        }
50
51
        if (!is_array($theConf) || strlen($theConf['plainType']) < 2) {
52
            $defaultOutput = $this->configuration['defaultOutput'];
53
            if ($defaultOutput && $myName) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $myName of type false|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
54
                $lines[] = str_replace('###CType###', $this->contentObject->data['CType'] . ': "' . $this->contentObject->data['list_type'] . '"; plugin: "' . $myName . '"; plainType: "' . (is_array($theConf) ? $theConf['plainType'] : '') . '"', $defaultOutput);
55
            }
56
        }
57
58
        $lines[] = $myContent;
59
        return $lines;
60
    }
61
}
62