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

3
namespace Tempest\Storage\Config;
4

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

8
final class S3StorageConfig implements StorageConfig
9
{
NEW
10
    public function __construct(
×
11
        /**
12
         * Name of the bucket.
13
         */
14
        public string $bucket,
15

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

21
        /**
22
         * If specified, scope operations to the that path.
23
         */
24
        public ?string $prefix = null,
25

26
        /**
27
         * Whether the storage is read-only.
28
         */
29
        public bool $readonly = false,
30

31
        /**
32
         * AWS access key ID. If null, the SDK will attempt to use the default credential provider chain (env vars, config files, IAM role).
33
         */
34
        public ?string $accessKeyId = null,
35

36
        /**
37
         * AWS secret cccess key. If null, the SDK will attempt to use the default credential provider chain.
38
         */
39
        public ?string $secretAccessKey = null,
40

41
        /**
42
         * AWS session token (typically used with temporary credentials). If null, the SDK will attempt to use the default credential provider chain.
43
         */
44
        public ?string $sessionToken = null,
45

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

51
        /**
52
         * 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).
53
         */
54
        public bool $usePathStyleEndpoint = false,
55

56
        /**
57
         * Other options.
58
         */
59
        public array $options = [],
NEW
60
    ) {}
×
61

NEW
62
    public function createAdapter(): AwsS3V3Adapter
×
63
    {
NEW
64
        return new AwsS3V3Adapter(
×
NEW
65
            client: new S3Client($this->buildClientConfig()),
×
NEW
66
            bucket: $this->bucket,
×
NEW
67
            prefix: $this->prefix,
×
NEW
68
        );
×
69
    }
70

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

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

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

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

NEW
93
        if ($this->options !== []) {
×
NEW
94
            return array_merge($config, $this->options);
×
95
        }
96

NEW
97
        return $config;
×
98
    }
99
}
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