-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathClient.php
More file actions
36 lines (30 loc) · 818 Bytes
/
Copy pathClient.php
File metadata and controls
36 lines (30 loc) · 818 Bytes
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
<?php
declare(strict_types=1);
namespace App\Structural\Adapter;
class Client
{
private FileAdapter $storageProvider;
/**
* @throws \Exception
*/
public function __construct(string $storage)
{
$this->storageProvider = match ($storage) {
'local' => new LocalFileStorage(),
'aws' => new AWSFileStorage(),
default => throw new \Exception("Unsupported storage requested $storage"),
};
}
public function save(string $filePath, string $name): void
{
$this->storageProvider->save($filePath, $name);
}
public function get(string $name): File
{
return $this->storageProvider->get($name);
}
public function delete(string $name)
{
return $this->storageProvider->delete($name);
}
}