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.

Model::createFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pnz\MattermostClient\Model;
6
7
abstract class Model implements CreatableFromArray
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $data;
13
14 35
    protected function __construct(array $data)
15
    {
16 35
        $this->data = $data;
17 35
    }
18
19 35
    public static function createFromArray(array $data)
20
    {
21
        // Clearing the data
22 35
        $emptyModel = array_fill_keys(static::getFields(), null);
23
24 35
        $data = array_merge($emptyModel, array_intersect_key($data, $emptyModel));
25
26 35
        return new static($data);
27
    }
28
29
    /**
30
     * @return string[]
31
     */
32
    abstract protected static function getFields(): array;
33
}
34