Total Complexity | 8 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait BaseInterface { |
||
8 | /** |
||
9 | * @return static |
||
10 | */ |
||
11 | public static function fromJson(string $json) { |
||
12 | $data = json_decode($json, true); |
||
13 | try { |
||
14 | return transform(static::class, $data); |
||
15 | } catch (\Exception $transformException) { |
||
16 | echo json_encode($transformException, JSON_PRETTY_PRINT); |
||
17 | throw $transformException; |
||
18 | } |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return static |
||
23 | */ |
||
24 | public static function fromFile(string $file) { |
||
25 | $content = file_get_contents($file); |
||
26 | return static::fromJson($content); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return static|null |
||
31 | */ |
||
32 | public static function fromCachedFile(string $file) { |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return static |
||
48 | */ |
||
49 | public static function fromArray(array $data) { |
||
58 |