-
-
Notifications
You must be signed in to change notification settings - Fork 453
Expand file tree
/
Copy pathStorage.php
More file actions
43 lines (33 loc) · 857 Bytes
/
Storage.php
File metadata and controls
43 lines (33 loc) · 857 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
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Kreait\Firebase;
use Google\Cloud\Storage\Bucket;
use Google\Cloud\Storage\StorageClient;
use function array_key_exists;
/**
* @internal
*/
final class Storage implements Contract\Storage
{
/**
* @var Bucket[]
*/
private array $buckets = [];
public function __construct(
private readonly StorageClient $storageClient,
private readonly string $defaultBucket,
) {
}
public function getStorageClient(): StorageClient
{
return $this->storageClient;
}
public function getBucket(?string $name = null): Bucket
{
$name ??= $this->defaultBucket;
if (!array_key_exists($name, $this->buckets)) {
$this->buckets[$name] = $this->storageClient->bucket($name);
}
return $this->buckets[$name];
}
}