• 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/S3StorageConfig.php
1
<?php
2

3
namespace Tempest\Storage\Config;
4

5
use Aws\S3\S3Client;
6
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
7
use League\Flysystem\FilesystemAdapter;
8

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

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

19
        /**
20
         * AWS region for the bucket (e.g., 'us-east-1', 'eu-west-1').
21
         */
22
        public string $region,
23

24
        /**
25
         * AWS access key ID. If null, the SDK will attempt to use the default credential provider chain (env vars, config files, IAM role).
26
         */
27
        public ?string $accessKeyId = null,
28

29
        /**
30
         * AWS secret cccess key. If null, the SDK will attempt to use the default credential provider chain.
31
         */
32
        public ?string $secretAccessKey = null,
33

34
        /**
35
         * AWS session token (typically used with temporary credentials). If null, the SDK will attempt to use the default credential provider chain.
36
         */
37
        public ?string $sessionToken = null,
38

39
        /**
40
         * If specified, scope operations to that path.
41
         */
42
        public ?string $prefix = null,
43

44
        /**
45
         * Whether the storage is read-only.
46
         */
47
        public bool $readonly = false,
48

49
        /**
50
         * Optional custom endpoint URL (e.g., for S3-compatible storage like R2).
51
         */
52
        public ?string $endpoint = null,
53

54
        /**
55
         * Set to true for S3-compatible storage that requires path-style addressing (e.g., http://localhost:9000/bucket/key). Defaults to false (virtual hosted-style: http://bucket.localhost:9000/key).
56
         */
57
        public bool $usePathStyleEndpoint = false,
58

59
        /**
60
         * Other options.
61
         */
62
        public array $options = [],
NEW
63
    ) {}
×
64

NEW
65
    public function createAdapter(): FilesystemAdapter
×
66
    {
NEW
67
        return new AwsS3V3Adapter(
×
NEW
68
            client: new S3Client($this->buildClientConfig()),
×
NEW
69
            bucket: $this->bucket,
×
NEW
70
            prefix: $this->prefix ?? '',
×
NEW
71
        );
×
72
    }
73

NEW
74
    private function buildClientConfig(): array
×
75
    {
NEW
76
        $config = [
×
NEW
77
            'region' => $this->region,
×
NEW
78
        ];
×
79

NEW
80
        if ($this->accessKeyId !== null && $this->secretAccessKey !== null) {
×
NEW
81
            $config['credentials'] = [
×
NEW
82
                'key' => $this->accessKeyId,
×
NEW
83
                'secret' => $this->secretAccessKey,
×
NEW
84
            ];
×
85

NEW
86
            if ($this->sessionToken !== null) {
×
NEW
87
                $config['credentials']['token'] = $this->sessionToken;
×
88
            }
89
        }
90

NEW
91
        if ($this->endpoint !== null) {
×
NEW
92
            $config['endpoint'] = $this->endpoint;
×
NEW
93
            $config['use_path_style_endpoint'] = $this->usePathStyleEndpoint;
×
94
        }
95

NEW
96
        if ($this->options !== []) {
×
NEW
97
            return array_merge($config, $this->options);
×
98
        }
99

NEW
100
        return $config;
×
101
    }
102
}
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