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.

HydratorStrategyTrait::set()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 4
nc 3
nop 4
crap 20
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Common;
4
5
/**
6
 * Represents common functionality for populating, or "hydrating", an object with arbitrary data.
7
 *
8
 * @package OpenStack\Common
9
 */
10
trait HydratorStrategyTrait
11
{
12
    /**
13
     * Hydrates an object with set data
14
     *
15
     * @param array $data    The data to set
16
     * @param array $aliases Any aliases
17
     */
18 220
    public function hydrate(array $data, array $aliases = [])
19
    {
20 220
        foreach ($data as $key => $val) {
21 220
            $key = isset($aliases[$key]) ? $aliases[$key] : $key;
22 220
            if (property_exists($this, $key)) {
23 220
                $this->{$key} = $val;
24 220
            }
25 220
        }
26 220
    }
27
28
    public function set(string $key, $property, array $data, callable $fn = null)
29
    {
30
        if (isset($data[$key]) && property_exists($this, $property)) {
31
            $value = $fn ? call_user_func($fn, $data[$key]) : $data[$key];
32
            $this->$property = $value;
33
        }
34
    }
35
}
36