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::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 6.28

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 12
rs 10
ccs 2
cts 7
cp 0.2857
crap 6.28
1
<?php
2
3
namespace NStack\Models;
4
5
use NStack\Exceptions\FailedToParseException;
6
7
abstract class Model
8
{
9
    /**
10
     * Model constructor.
11
     *
12
     * @param array $data
13
     * @throws \NStack\Exceptions\FailedToParseException
14
     * @author Casper Rasmussen <[email protected]>
15
     */
16 26
    public function __construct(array $data)
17
    {
18
        try {
19 26
            $this->parse($data);
20
        } catch (\Throwable $e) {
21
            $message = sprintf('Failed to parse %s: %s', get_called_class(), $e->getMessage());
22
23
            if (!empty($data['id'])) {
24
                $message .= ' ID: ' . $data['id'];
25
            }
26
27
            throw new FailedToParseException($message);
28
        }
29 26
    }
30
31
    public abstract function parse(array $data);
32
33
    public abstract function toArray(): array;
34
}