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 ( ad565c...b5b947 )
by Mewes
02:25
created

AbstractWrapper   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 0
loc 44
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
D setProperties() 0 33 9
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
     * @param string|null $column
18
     * @throws \RuntimeException
19
     */
20
    protected function setProperties(array $properties, array $mappings, string $column = null)
21
    {
22
        foreach ($properties as $key => $value) {
23
            if (!isset($mappings[$key])) {
24
                throw new \RuntimeException(sprintf('No mapping found for key "%s"', $key));
25
            }
26
27
            if (is_array($value) && is_array($mappings[$key])) {
28
                // recursion
29
                /**
30
                 * @var array $value
31
                 */
32
                if (isset($mappings[$key]['__multi'])) {
33
                    // handle multi target structure (with columns)
34
                    foreach ($value as $_column => $_value) {
35
                        $this->setProperties($_value, $mappings[$key], $_column);
36
                    }
37
                } else {
38
                    // handle single target structure
39
                    $this->setProperties($value, $mappings[$key]);
40
                }
41
            } elseif (is_callable($mappings[$key])) {
42
                // call single and multi target mapping
43
                // if column is set it is used to get object from the callback in __multi
44
                $mappings[$key](
45
                    $value,
46
                    $column !== null ? $mappings['__multi']($column) : null
47
                );
48
            } else {
49
                throw new \RuntimeException(sprintf('Invalid mapping for key "%s"', $key));
50
            }
51
        }
52
    }
53
}
54