File tree Expand file tree Collapse file tree 3 files changed +35
-53
lines changed Expand file tree Collapse file tree 3 files changed +35
-53
lines changed Original file line number Diff line number Diff line change 22
33namespace Spatie \Snapshots ;
44
5- interface Filesystem
5+ class Filesystem
66{
7- public function path (string $ filename ): string ;
7+ /** @var string */
8+ private $ basePath ;
89
9- public function has (string $ filename ): bool ;
10+ public function __construct (string $ basePath )
11+ {
12+ $ this ->basePath = $ basePath ;
13+ }
1014
11- public function read (string $ filename ): bool ;
15+ public static function inDirectory (string $ path ): self
16+ {
17+ return new self ($ path );
18+ }
1219
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+ }
1443}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22
33namespace Spatie \Snapshots ;
44
5- use Spatie \Snapshots \Filesystems \LocalFilesystem ;
6-
75class Snapshot
86{
97 /** @var string */
@@ -31,7 +29,7 @@ public static function forTestCase(
3129 string $ directory ,
3230 Driver $ driver
3331 ): self {
34- $ filesystem = LocalFilesystem ::inDirectory ($ directory );
32+ $ filesystem = Filesystem ::inDirectory ($ directory );
3533
3634 $ id = "{$ namespace }__ {$ test }" ;
3735
You can’t perform that action at this time.
0 commit comments