ArrayTransformViewHelper::render()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 4
nop 1
1
<?php
2
/**
3
 * Class ArrayTransformViewHelper
4
 */
5
6
namespace HDNET\OnpageIntegration\ViewHelpers;
7
8
/**
9
 * Class ArrayTransformViewHelper
10
 */
11
class ArrayTransformViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
12
{
13
14
    /**
15
     * @var array
16
     */
17
    protected $transformedLastCrawl = [
18
        'working_page'          => false,
19
        'working_external_link' => false,
20
        'working_asset'         => false,
21
        'working_image'         => false,
22
        'broken_page'           => false,
23
        'broken_external_link'  => false,
24
        'broken_asset'          => false,
25
        'broken_image'          => false
26
    ];
27
28
    /**
29
     * Transformed the numeric last crawl array into a associative array
30
     *
31
     * @param mixed $lastCrawl
32
     *
33
     * @return array
34
     */
35
    public function render($lastCrawl)
36
    {
37
        foreach ($lastCrawl as $lastCrawlElement) {
38
            foreach ($this->transformedLastCrawl as $key => $element) {
39
                if ($lastCrawlElement['inventory_group'] === $key) {
40
                    $this->transformedLastCrawl[$key] = $lastCrawlElement['count'];
41
                }
42
            }
43
        }
44
        return $this->transformedLastCrawl;
45
    }
46
}
47