Skip to content

Commit 83155ef

Browse files
committed
GrifFS protocol don't need to be configurable
1 parent 295ccac commit 83155ef

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/GridFS/Bucket.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ class Bucket
8585

8686
private ?DocumentCodec $codec = null;
8787

88-
private string $protocol;
89-
9088
private CollectionWrapper $collectionWrapper;
9189

9290
private string $databaseName;
@@ -137,16 +135,11 @@ class Bucket
137135
public function __construct(Manager $manager, string $databaseName, array $options = [])
138136
{
139137
$options += [
140-
'protocol' => self::STREAM_WRAPPER_PROTOCOL,
141138
'bucketName' => self::DEFAULT_BUCKET_NAME,
142139
'chunkSizeBytes' => self::DEFAULT_CHUNK_SIZE_BYTES,
143140
'disableMD5' => false,
144141
];
145142

146-
if (! is_string($options['protocol'])) {
147-
throw InvalidArgumentException::invalidType('"protocol" option', $options['protocol'], 'string');
148-
}
149-
150143
if (! is_string($options['bucketName'])) {
151144
throw InvalidArgumentException::invalidType('"bucketName" option', $options['bucketName'], 'string');
152145
}
@@ -189,7 +182,6 @@ public function __construct(Manager $manager, string $databaseName, array $optio
189182

190183
$this->manager = $manager;
191184
$this->databaseName = $databaseName;
192-
$this->protocol = $options['protocol'];
193185
$this->bucketName = $options['bucketName'];
194186
$this->chunkSizeBytes = $options['chunkSizeBytes'];
195187
$this->codec = $options['codec'] ?? null;
@@ -596,7 +588,7 @@ public function openUploadStream(string $filename, array $options = [])
596588

597589
$path = $this->createPathForUpload();
598590
$context = stream_context_create([
599-
$this->protocol => [
591+
self::STREAM_WRAPPER_PROTOCOL => [
600592
'collectionWrapper' => $this->collectionWrapper,
601593
'filename' => $filename,
602594
'options' => $options,
@@ -742,7 +734,7 @@ private function createPathForFile(object $file): string
742734

743735
return sprintf(
744736
'%s://%s/%s.files/%s',
745-
$this->protocol,
737+
self::STREAM_WRAPPER_PROTOCOL,
746738
urlencode($this->databaseName),
747739
urlencode($this->bucketName),
748740
urlencode($id),
@@ -804,7 +796,7 @@ private function openDownloadStreamByFile(object $file)
804796
{
805797
$path = $this->createPathForFile($file);
806798
$context = stream_context_create([
807-
$this->protocol => [
799+
self::STREAM_WRAPPER_PROTOCOL => [
808800
'collectionWrapper' => $this->collectionWrapper,
809801
'file' => $file,
810802
],
@@ -818,10 +810,10 @@ private function openDownloadStreamByFile(object $file)
818810
*/
819811
private function registerStreamWrapper(): void
820812
{
821-
if (in_array($this->protocol, stream_get_wrappers())) {
813+
if (in_array(self::STREAM_WRAPPER_PROTOCOL, stream_get_wrappers())) {
822814
return;
823815
}
824816

825-
StreamWrapper::register($this->protocol);
817+
StreamWrapper::register(self::STREAM_WRAPPER_PROTOCOL);
826818
}
827819
}

0 commit comments

Comments
 (0)