Completed
Push — master ( 8687c2...995275 )
by Steve
02:00
created

Helpers.php ➔ json_encode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace MeadSteve\DiceApi\Helpers;
3
4
function file_contents(string $path): string
5
{
6
    $contents = \file_get_contents($path);
7
    if ($contents === false) {
8
        throw new \RuntimeException("Unable to load from {$path}");
9
    }
10
    return $contents;
11
}
12
13
function json_encode($data): string
14
{
15
    $encoded = \json_encode($data);
16
    if ($encoded === false) {
17
        throw new \RuntimeException("Unable to encode json data");
18
    }
19
    return $encoded;
20
}
21