Passed
Pull Request — master (#1856)
by
unknown
04:46
created

BaseInterface   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromJson() 0 7 2
1
<?php
2
3
namespace MySociety\TheyWorkForYou\DataClass;
4
5
use function Rutek\Dataclass\transform;
6
7
trait BaseInterface {
8
    public static function fromJson(string $json): self {
9
        $data = json_decode($json, true);
10
        try {
11
            return transform(static::class, $data);
12
        } catch (\Exception $transformException) {
13
            echo json_encode($transformException, JSON_PRETTY_PRINT);
14
            throw $transformException;
15
        }
16
    }
17
}
18