forked from thephpleague/flysystem-google-cloud-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStubStorageClient.php
37 lines (28 loc) · 921 Bytes
/
StubStorageClient.php
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
<?php
declare(strict_types=1);
namespace League\Flysystem\GoogleCloudStorage;
use Google\Cloud\Storage\StorageClient;
use function in_array;
class StubStorageClient extends StorageClient
{
private ?StubRiggedBucket $riggedBucket = null;
public function __construct(array $config = [])
{
parent::__construct($config);
}
/**
* @var string|null
*/
protected $projectId;
public function bucket($name, $userProject = false)
{
$knownBuckets = ['flysystem', 'no-acl-bucket-for-ci'];
$isKnownBucket = in_array($name, $knownBuckets);
if ($isKnownBucket && ! $this->riggedBucket) {
$this->riggedBucket = new StubRiggedBucket($this->connection, $name, [
'requesterProjectId' => $this->projectId,
]);
}
return $isKnownBucket ? $this->riggedBucket : parent::bucket($name, $userProject);
}
}