Completed
Push — develop ( 279bca...3f20e4 )
by
unknown
03:15
created

MetaDataProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace HDNET\OnpageIntegration\Provider;
4
5
use HDNET\OnpageIntegration\Provider\Configuration;
6
use TYPO3\CMS\Core\Utility\GeneralUtility;
7
use HDNET\OnpageIntegration\Service\ArrayService;
8
9
class MetaDataProvider
10
{
11
    /**
12
     * @var Configuration
13
     */
14
    protected $configurationProvider;
15
    /**
16
     * @var ArrayService
17
     */
18
    protected $arrayService;
19
20
    public function __construct()
21
    {
22
        $this->configurationProvider = GeneralUtility::makeInstance(Configuration::class);
23
        $this->arrayService          = GeneralUtility::makeInstance(ArrayService::class);
24
    }
25
26
    /**
27
     * @param string $key
28
     * @return array
29
     */
30
    public function getMetaData($key)
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
        $configData = $this->configurationProvider->getAllConfigurationData();
33
        $searchKeys = ['description', 'priority'];
34
35
        $elements = $this->arrayService->findElement($configData, 'seoaspects');
36
37
        return $this->buildData($elements, $searchKeys);
38
    }
39
40
    /**
41
     * @param array $array
42
     * @param array $searchKeys
43
     * @return array
44
     */
45
    protected function buildData(array $array, array $searchKeys)
46
    {
47
        $tmp = [];
48
49
        foreach ($array as $key => $element) {
50
            $tmp[$key] = $this->filter($element, $searchKeys);
51
        }
52
53
        return $tmp;
54
    }
55
56
    /**
57
     * @param array $array
58
     * @param array $searchKeys
59
     * @return array
60
     */
61
    protected function filter(array $array, array $searchKeys)
62
    {
63
        $tmp = [];
64
65
        foreach ($array as $key => $element) {
66
            if (in_array($key, $searchKeys)) {
67
                $tmp[$key] = $element;
68
            }
69
        }
70
71
        return $tmp;
72
    }
73
}
74