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   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 9 4
A set() 0 7 4
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