File tree 3 files changed +35
-53
lines changed
3 files changed +35
-53
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Spatie \Snapshots ;
4
4
5
- interface Filesystem
5
+ class Filesystem
6
6
{
7
- public function path (string $ filename ): string ;
7
+ /** @var string */
8
+ private $ basePath ;
8
9
9
- public function has (string $ filename ): bool ;
10
+ public function __construct (string $ basePath )
11
+ {
12
+ $ this ->basePath = $ basePath ;
13
+ }
10
14
11
- public function read (string $ filename ): bool ;
15
+ public static function inDirectory (string $ path ): self
16
+ {
17
+ return new self ($ path );
18
+ }
12
19
13
- public function put (string $ filename , string $ contents );
20
+ public function path (string $ filename ): string
21
+ {
22
+ return $ this ->basePath .DIRECTORY_SEPARATOR .$ filename ;
23
+ }
24
+
25
+ public function has (string $ filename ): bool
26
+ {
27
+ return file_exists ($ this ->path ($ filename ));
28
+ }
29
+
30
+ public function read (string $ filename ): bool
31
+ {
32
+ return file_get_contents ($ this ->path ($ filename ));
33
+ }
34
+
35
+ public function put (string $ filename , string $ contents )
36
+ {
37
+ if (! file_exists ($ this ->basePath )) {
38
+ mkdir ($ this ->basePath );
39
+ }
40
+
41
+ file_put_contents ($ this ->path ($ filename ), $ contents );
42
+ }
14
43
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
3
3
namespace Spatie \Snapshots ;
4
4
5
- use Spatie \Snapshots \Filesystems \LocalFilesystem ;
6
-
7
5
class Snapshot
8
6
{
9
7
/** @var string */
@@ -31,7 +29,7 @@ public static function forTestCase(
31
29
string $ directory ,
32
30
Driver $ driver
33
31
): self {
34
- $ filesystem = LocalFilesystem ::inDirectory ($ directory );
32
+ $ filesystem = Filesystem ::inDirectory ($ directory );
35
33
36
34
$ id = "{$ namespace }__ {$ test }" ;
37
35
You can’t perform that action at this time.
0 commit comments