• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14422676564

12 Apr 2025 07:23PM UTC coverage: 80.298% (-0.9%) from 81.217%
14422676564

Pull #1149

github

web-flow
Merge 72596e199 into 0c553d46c
Pull Request #1149: feat(storage): add storage component

137 of 333 new or added lines in 18 files covered. (41.14%)

11685 of 14552 relevant lines covered (80.3%)

104.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Tempest/Storage/src/Config/GoogleCloudStorageConfig.php
1
<?php
2

3
namespace Tempest\Storage\Config;
4

5
use Google\Cloud\Storage\StorageClient;
6
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
7
use League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter;
8
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
9

10
final class GoogleCloudStorageConfig implements StorageConfig
11
{
NEW
12
    public function __construct(
×
13
        /**
14
         * Name of the bucket to use.
15
         */
16
        public string $bucket,
17

18
        /**
19
         * The Google Cloud project ID. May be inferred from credentials.
20
         */
21
        public ?string $projectId = null,
22

23
        /**
24
         * Absolute path to the JSON file containing the service account credentials.
25
         */
26
        public ?string $keyFilePath = null,
27

28
        /**
29
         * May be used to connect to a non-standard GCS endpoint.
30
         */
31
        public ?string $apiEndpoint = null,
32

33
        /**
34
         * Prefix to be used for all paths.
35
         */
36
        public string $prefix = '',
37

38
        /**
39
         * Less common options.
40
         */
41
        public array $options = [],
42

43
        /**
44
         * Whether the storage is read-only.
45
         */
46
        public bool $readonly = false,
NEW
47
    ) {}
×
48

NEW
49
    public function createAdapter(): GoogleCloudStorageAdapter
×
50
    {
NEW
51
        $client = new StorageClient($this->buildClientConfig());
×
52

NEW
53
        return new GoogleCloudStorageAdapter(
×
NEW
54
            bucket: $client->bucket($this->bucket),
×
NEW
55
            prefix: $this->prefix,
×
NEW
56
        );
×
57
    }
58

NEW
59
    private function buildClientConfig(): array
×
60
    {
NEW
61
        $config = [];
×
62

NEW
63
        if ($this->projectId !== null) {
×
NEW
64
            $config['projectId'] = $this->projectId;
×
65
        }
66

NEW
67
        if ($this->keyFilePath !== null) {
×
NEW
68
            $config['keyFilePath'] = $this->keyFilePath;
×
69
        }
70

NEW
71
        if ($this->apiEndpoint !== null) {
×
NEW
72
            $config['apiEndpoint'] = $this->apiEndpoint;
×
73
        }
74

NEW
75
        if ($this->options !== []) {
×
NEW
76
            return array_merge($config, $this->options);
×
77
        }
78

NEW
79
        return $config;
×
80
    }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc