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 ( dea5e9...4057a0 )
by Mewes
02:21
created

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