Completed
Push — develop ( f4b279...a19c81 )
by René
17:42
created

ArrayTransformViewHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 11 4
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