Templavoila   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderInternal() 0 16 3
1
<?php
2
/**
3
 * Render templavoila
4
 *
5
 * @author Tim Lochmüller
6
 */
7
8
namespace FRUIT\Ink\Rendering;
9
10
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12
13
/**
14
 * Render templavoila
15
 */
16
class Templavoila extends AbstractRendering
17
{
18
19
    /**
20
     * Render the given element
21
     *
22
     * @return array
23
     */
24
    public function renderInternal()
25
    {
26
27
        // TV nicht geladen
28
        if (!ExtensionManagementUtility::isLoaded('templavoila')) {
29
            $defaultOutput = $this->configuration['defaultOutput'];
30
            if ($defaultOutput) {
31
                $defaultOutput = str_replace('###CType###', $this->contentObject->data['CType'], $defaultOutput);
32
            }
33
            return $defaultOutput;
34
        }
35
        $pi1 = GeneralUtility::makeInstance('tx_templavoila_pi1');
36
        $pi1->cObj = $this->contentObject;
37
        $lines[] = $pi1->renderElement($this->contentObject->data, 'tt_content');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$lines was never initialized. Although not strictly required by PHP, it is generally a good practice to add $lines = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
38
        return $lines;
39
    }
40
}
41