GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5f6b2b...ad565c )
by Mewes
02:16
created

AbstractWrapper   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 13
lcom 0
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B setProperties() 0 21 8
B setPropertiesByKey() 0 14 5
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Wrapper;
4
5
/**
6
 * Class AbstractWrapper
7
 *
8
 * @package MewesK\TwigSpreadsheetBundle\Wrapper
9
 */
10
abstract class AbstractWrapper
11
{
12
    /**
13
     * Calls the matching mapping callable for each property.
14
     *
15
     * @param array $properties
16
     * @param array $mappings
17
     * @throws \RuntimeException
18
     */
19
    protected function setProperties(array $properties, array $mappings)
20
    {
21
        foreach ($properties as $key => $value) {
22
            if (is_array($value) && is_array($mappings[$key])) {
23
                if (isset($mappings[$key]['__multi']) && $mappings[$key]['__multi'] === true) {
24
                    /**
25
                     * @var array $value
26
                     */
27
                    foreach ($value as $_key => $_value) {
28
                        $this->setPropertiesByKey($_key, $_value, $mappings[$key]);
29
                    }
30
                } else {
31
                    $this->setProperties($value, $mappings[$key]);
32
                }
33
            } elseif (is_callable($mappings[$key])) {
34
                $mappings[$key]($value);
35
            } else {
36
                throw new \RuntimeException(sprintf('Invalid mapping with key "%s"', $key));
37
            }
38
        }
39
    }
40
41
    /**
42
     * @param string $key
43
     * @param array $properties
44
     * @param array $mappings
45
     * @throws \RuntimeException
46
     */
47
    private function setPropertiesByKey(string $key, array $properties, array $mappings)
48
    {
49
        foreach ($properties as $_key => $value) {
50
            if (isset($mappings[$_key])) {
51
                if (is_array($value)) {
52
                    $this->setPropertiesByKey($key, $value, $mappings[$_key]);
53
                } elseif(is_callable($mappings[$_key])) {
54
                    $mappings[$_key]($key, $value);
55
                } else {
56
                    throw new \RuntimeException(sprintf('Invalid mapping with key "%s"', $_key));
57
                }
58
            }
59
        }
60
    }
61
}
62