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

tempestphp / tempest-framework / 14429341969

13 Apr 2025 12:12PM UTC coverage: 80.175% (-1.0%) from 81.217%
14429341969

Pull #1149

github

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

200 of 434 new or added lines in 22 files covered. (46.08%)

11748 of 14653 relevant lines covered (80.17%)

104.55 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\FilesystemAdapter;
7
use League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter;
8

9
final class GoogleCloudStorageConfig implements StorageConfig
10
{
11
    public string $adapter = GoogleCloudStorageAdapter::class;
12

NEW
13
    public function __construct(
×
14
        /**
15
         * Name of the bucket to use.
16
         */
17
        public string $bucket,
18

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

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

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

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

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

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

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

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

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

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

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

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

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

NEW
80
        return $config;
×
81
    }
82
}
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