@@ -85,8 +85,6 @@ class Bucket
85
85
86
86
private ?DocumentCodec $ codec = null ;
87
87
88
- private string $ protocol ;
89
-
90
88
private CollectionWrapper $ collectionWrapper ;
91
89
92
90
private string $ databaseName ;
@@ -137,16 +135,11 @@ class Bucket
137
135
public function __construct (Manager $ manager , string $ databaseName , array $ options = [])
138
136
{
139
137
$ options += [
140
- 'protocol ' => self ::STREAM_WRAPPER_PROTOCOL ,
141
138
'bucketName ' => self ::DEFAULT_BUCKET_NAME ,
142
139
'chunkSizeBytes ' => self ::DEFAULT_CHUNK_SIZE_BYTES ,
143
140
'disableMD5 ' => false ,
144
141
];
145
142
146
- if (! is_string ($ options ['protocol ' ])) {
147
- throw InvalidArgumentException::invalidType ('"protocol" option ' , $ options ['protocol ' ], 'string ' );
148
- }
149
-
150
143
if (! is_string ($ options ['bucketName ' ])) {
151
144
throw InvalidArgumentException::invalidType ('"bucketName" option ' , $ options ['bucketName ' ], 'string ' );
152
145
}
@@ -189,7 +182,6 @@ public function __construct(Manager $manager, string $databaseName, array $optio
189
182
190
183
$ this ->manager = $ manager ;
191
184
$ this ->databaseName = $ databaseName ;
192
- $ this ->protocol = $ options ['protocol ' ];
193
185
$ this ->bucketName = $ options ['bucketName ' ];
194
186
$ this ->chunkSizeBytes = $ options ['chunkSizeBytes ' ];
195
187
$ this ->codec = $ options ['codec ' ] ?? null ;
@@ -596,7 +588,7 @@ public function openUploadStream(string $filename, array $options = [])
596
588
597
589
$ path = $ this ->createPathForUpload ();
598
590
$ context = stream_context_create ([
599
- $ this -> protocol => [
591
+ self :: STREAM_WRAPPER_PROTOCOL => [
600
592
'collectionWrapper ' => $ this ->collectionWrapper ,
601
593
'filename ' => $ filename ,
602
594
'options ' => $ options ,
@@ -742,7 +734,7 @@ private function createPathForFile(object $file): string
742
734
743
735
return sprintf (
744
736
'%s://%s/%s.files/%s ' ,
745
- $ this -> protocol ,
737
+ self :: STREAM_WRAPPER_PROTOCOL ,
746
738
urlencode ($ this ->databaseName ),
747
739
urlencode ($ this ->bucketName ),
748
740
urlencode ($ id ),
@@ -804,7 +796,7 @@ private function openDownloadStreamByFile(object $file)
804
796
{
805
797
$ path = $ this ->createPathForFile ($ file );
806
798
$ context = stream_context_create ([
807
- $ this -> protocol => [
799
+ self :: STREAM_WRAPPER_PROTOCOL => [
808
800
'collectionWrapper ' => $ this ->collectionWrapper ,
809
801
'file ' => $ file ,
810
802
],
@@ -818,10 +810,10 @@ private function openDownloadStreamByFile(object $file)
818
810
*/
819
811
private function registerStreamWrapper (): void
820
812
{
821
- if (in_array ($ this -> protocol , stream_get_wrappers ())) {
813
+ if (in_array (self :: STREAM_WRAPPER_PROTOCOL , stream_get_wrappers ())) {
822
814
return ;
823
815
}
824
816
825
- StreamWrapper::register ($ this -> protocol );
817
+ StreamWrapper::register (self :: STREAM_WRAPPER_PROTOCOL );
826
818
}
827
819
}
0 commit comments