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 ( e23e5a...cfdab8 )
by Sebastian
03:19 queued 01:40
created

YamlDriver::serialize()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
3
namespace Spatie\Snapshots\Drivers;
4
5
use PHPUnit\Framework\Assert;
6
use Spatie\Snapshots\Driver;
7
use Spatie\Snapshots\Exceptions\CantBeSerialized;
8
use Symfony\Component\Yaml\Yaml;
9
10
class YamlDriver implements Driver
11
{
12
    public function serialize($data): string
13
    {
14
        if (is_string($data)) {
15
            $data = Yaml::parse($data);
16
        }
17
18
        if (! is_array($data)) {
19
            throw new CantBeSerialized('Only strings can be serialized to json');
20
        }
21
22
        return Yaml::dump($data, PHP_INT_MAX);
23
    }
24
25
    public function extension(): string
26
    {
27
        return 'yml';
28
    }
29
30
    public function match($expected, $actual)
31
    {
32
        if (is_array($actual)) {
33
            $actual = Yaml::dump($actual, PHP_INT_MAX);
34
        }
35
36
        Assert::assertEquals($expected, $actual);
37
    }
38
}
39