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::setProperties()   D

Complexity

Conditions 9
Paths 6

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 4.909
c 0
b 0
f 0
cc 9
eloc 16
nc 6
nop 3
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