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

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createFromArray() 0 8 1
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