-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFlysystemFilesystem.php
More file actions
42 lines (34 loc) · 1.17 KB
/
FlysystemFilesystem.php
File metadata and controls
42 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
/*
* This file is part of the community-maintained Playwright PHP project.
* It is not affiliated with or endorsed by Microsoft.
*
* (c) 2025-Present - Playwright PHP - https://github.com/playwright-php
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Playwright\Media\Filesystem;
use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemAdapter;
use League\Flysystem\FilesystemException;
use League\Flysystem\UnableToWriteFile;
use Playwright\Exception\RuntimeException;
final readonly class FlysystemFilesystem implements FilesystemInterface
{
private Filesystem $filesystem;
public function __construct(FilesystemAdapter $adapter)
{
$this->filesystem = new Filesystem($adapter);
}
public function write(string $path, string $content): string
{
try {
$this->filesystem->write($path, $content);
} catch (FilesystemException|UnableToWriteFile $e) {
throw new RuntimeException(sprintf('Failed to write screenshot to file: %s', $path), 0, $e);
}
return $path;
}
}