forked from jkapuscik2/design-patterns-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.php
More file actions
38 lines (29 loc) · 950 Bytes
/
Client.php
File metadata and controls
38 lines (29 loc) · 950 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
37
38
<?php
namespace Structural\Adapter;
class Client {
private $storageProvider;
public function __construct (string $storage) {
switch ($storage) {
case 'local':
$this->storageProvider = new LocalFileStorage();
break;
case 'azure':
$this->storageProvider = new AzureFileStorage();
break;
case 'aws':
$this->storageProvider = new AWSFileStorage();
break;
default:
throw new \Exception("Unsupported storage requested $storage");
}
}
public function save (string $filePath, string $name) {
$this->storageProvider->save($filePath, $name);
}
public function get (string $name) {
return $this->storageProvider->get($name);
}
public function delete (string $name) {
return $this->storageProvider->delete($name);
}
}