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.
Completed
Push — master ( 608362...8df995 )
by Sebastian
01:53
created

JsonDriver::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Snapshots\Drivers;
4
5
use PHPUnit\Framework\Assert;
6
use PHPUnit\Framework\Constraint\JsonMatches;
7
use Spatie\Snapshots\Driver;
8
use Spatie\Snapshots\Exceptions\CantBeSerialized;
9
10
class JsonDriver implements Driver
11
{
12
    public function serialize($data): string
13
    {
14
        if (! is_string($data)) {
15
            throw new CantBeSerialized('Only strings can be serialized to json');
16
        }
17
18
        return json_encode(json_decode($data), JSON_PRETTY_PRINT).PHP_EOL;
19
    }
20
21
    public function extension(): string
22
    {
23
        return '.json';
24
    }
25
26
    public function match($expected, $actual)
27
    {
28
        Assert::assertJson($expected);
29
        Assert::assertJson($actual);
30
31
        Assert::assertThat($actual, new JsonMatches($expected));
32
    }
33
}
34