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

XmlDriver::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 DOMDocument;
6
use PHPUnit\Framework\Assert;
7
use PHPUnit\Util\Xml;
8
use Spatie\Snapshots\Driver;
9
use Spatie\Snapshots\Exceptions\CantBeSerialized;
10
11
class XmlDriver implements Driver
12
{
13
    public function serialize($data): string
14
    {
15
        if (! is_string($data)) {
16
            throw new CantBeSerialized('Only strings can be serialized to xml');
17
        }
18
19
        $domDocument = new DOMDocument('1.0');
20
        $domDocument->preserveWhiteSpace = false;
21
        $domDocument->formatOutput = true;
22
23
        $domDocument->loadXML($data);
24
25
        return $domDocument->saveXML();
26
    }
27
28
    public function extension(): string
29
    {
30
        return '.xml';
31
    }
32
33
    public function match($expected, $actual)
34
    {
35
        Assert::assertEquals(Xml::load($expected), Xml::load($actual));
36
    }
37
}
38