allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
50
vendor/kreait/firebase-php/src/Firebase/Storage.php
vendored
Normal file
50
vendor/kreait/firebase-php/src/Firebase/Storage.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kreait\Firebase;
|
||||
|
||||
use Google\Cloud\Storage\Bucket;
|
||||
use Google\Cloud\Storage\StorageClient;
|
||||
use Kreait\Firebase\Exception\RuntimeException;
|
||||
|
||||
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 = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getStorageClient(): StorageClient
|
||||
{
|
||||
return $this->storageClient;
|
||||
}
|
||||
|
||||
public function getBucket(?string $name = null): Bucket
|
||||
{
|
||||
$name ??= $this->defaultBucket;
|
||||
|
||||
if ($name === null) {
|
||||
throw new RuntimeException(
|
||||
'No bucket name was given and no default bucked was configured.',
|
||||
);
|
||||
}
|
||||
|
||||
if (!array_key_exists($name, $this->buckets)) {
|
||||
$this->buckets[$name] = $this->storageClient->bucket($name);
|
||||
}
|
||||
|
||||
return $this->buckets[$name];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user