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

Snapshot   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 56
c 0
b 0
f 0
wmc 7
lcom 1
cbo 2
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A forTestCase() 0 9 1
A id() 0 4 1
A filename() 0 4 1
A exists() 0 4 1
A assertMatches() 0 4 1
A create() 0 4 1
1
<?php
2
3
namespace Spatie\Snapshots;
4
5
class Snapshot
6
{
7
    /** @var string */
8
    private $id;
9
10
    /** @var \Spatie\Snapshots\Filesystem */
11
    private $filesystem;
12
13
    /** @var \Spatie\Snapshots\Driver */
14
    private $driver;
15
16
    public function __construct(
17
        string $id,
18
        Filesystem $filesystem,
19
        Driver $driver
20
    ) {
21
        $this->id = $id;
22
        $this->filesystem = $filesystem;
23
        $this->driver = $driver;
24
    }
25
26
    public static function forTestCase(
27
        string $id,
28
        string $directory,
29
        Driver $driver
30
    ): self {
31
        $filesystem = Filesystem::inDirectory($directory);
32
33
        return new self($id, $filesystem, $driver);
34
    }
35
36
    public function id(): string
37
    {
38
        return $this->id;
39
    }
40
41
    public function filename(): string
42
    {
43
        return $this->id.$this->driver->extension();
44
    }
45
46
    public function exists(): bool
47
    {
48
        return $this->filesystem->has($this->filename());
49
    }
50
51
    public function assertMatches($actual)
52
    {
53
        $this->driver->match($this->filesystem->read($this->filename()), $actual);
54
    }
55
56
    public function create($actual)
57
    {
58
        $this->filesystem->put($this->filename(), $this->driver->serialize($actual));
59
    }
60
}
61