Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
c674aac2
Commit
c674aac2
authored
Mar 19, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-141: Remove InvalidArgumentTypeException in GridFS
parent
03e9decb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
14 deletions
+13
-14
Bucket.php
src/GridFS/Bucket.php
+5
-5
GridFSCollectionsWrapper.php
src/GridFS/GridFSCollectionsWrapper.php
+0
-1
GridFSUpload.php
src/GridFS/GridFSUpload.php
+6
-6
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+1
-1
GridFSStreamTest.php
tests/GridFS/GridFSStreamTest.php
+1
-1
No files found.
src/GridFS/Bucket.php
View file @
c674aac2
...
...
@@ -6,7 +6,7 @@ use MongoDB\BSON\ObjectId;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Exception\GridFSFileNotFoundException
;
use
MongoDB\Exception\InvalidArgument
Type
Exception
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Operation\Find
;
/**
...
...
@@ -51,19 +51,19 @@ class Bucket
];
if
(
isset
(
$options
[
'bucketName'
])
&&
!
is_string
(
$options
[
'bucketName'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bucketName" option'
,
$options
[
'bucketName'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"bucketName" option'
,
$options
[
'bucketName'
],
'string'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
throw
new
InvalidArgumentTypeException
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/GridFS/GridFSCollectionsWrapper.php
View file @
c674aac2
...
...
@@ -6,7 +6,6 @@ use MongoDB\Collection;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
* GridFSCollectionsWrapper abstracts the GridFS files and chunks collections.
...
...
src/GridFS/GridFSUpload.php
View file @
c674aac2
...
...
@@ -6,7 +6,7 @@ use MongoDB\BSON\Binary;
use
MongoDB\BSON\ObjectId
;
use
MongoDB\BSON\UTCDateTime
;
use
MongoDB\Driver\Exception\Exception
;
use
MongoDB\Exception\InvalidArgument
Type
Exception
;
use
MongoDB\Exception\InvalidArgumentException
;
/**
* GridFSUpload abstracts the process of writing a GridFS file.
...
...
@@ -47,22 +47,22 @@ class GridFSUpload
* @param GridFSCollectionsWrapper $collectionsWrapper GridFS collections wrapper
* @param string $filename File name
* @param array $options Upload options
* @throws InvalidArgument
Type
Exception
* @throws InvalidArgumentException
*/
public
function
__construct
(
GridFSCollectionsWrapper
$collectionsWrapper
,
$filename
,
array
$options
=
[])
{
$options
+=
[
'chunkSizeBytes'
=>
261120
];
if
(
isset
(
$options
[
'aliases'
])
&&
!
\MongoDB\is_string_array
(
$options
[
'aliases'
]))
{
throw
new
InvalidArgumentTypeException
(
'"aliases" option'
,
$options
[
'aliases'
],
'array of strings'
);
throw
InvalidArgumentException
::
invalidType
(
'"aliases" option'
,
$options
[
'aliases'
],
'array of strings'
);
}
if
(
isset
(
$options
[
'contentType'
])
&&
!
is_string
(
$options
[
'contentType'
]))
{
throw
new
InvalidArgumentTypeException
(
'"contentType" option'
,
$options
[
'contentType'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"contentType" option'
,
$options
[
'contentType'
],
'string'
);
}
if
(
isset
(
$options
[
'metadata'
])
&&
!
is_array
(
$options
[
'metadata'
])
&&
!
is_object
(
$options
[
'metadata'
]))
{
throw
new
InvalidArgumentTypeException
(
'"metadata" option'
,
$options
[
'metadata'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"metadata" option'
,
$options
[
'metadata'
],
'array or object'
);
}
$this
->
chunkSize
=
$options
[
'chunkSizeBytes'
];
...
...
@@ -175,7 +175,7 @@ class GridFSUpload
public
function
uploadFromStream
(
$source
)
{
if
(
!
is_resource
(
$source
)
||
get_resource_type
(
$source
)
!=
"stream"
)
{
throw
new
InvalidArgumentTypeException
(
'$stream
'
,
$source
,
'resource'
);
throw
InvalidArgumentException
::
invalidType
(
'$source
'
,
$source
,
'resource'
);
}
$streamMetadata
=
stream_get_meta_data
(
$source
);
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
c674aac2
...
...
@@ -11,7 +11,7 @@ class BucketFunctionalTest extends FunctionalTestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/GridFS/GridFSStreamTest.php
View file @
c674aac2
...
...
@@ -222,7 +222,7 @@ class GridFSStreamTest extends FunctionalTestCase
$download
->
close
();
}
/**
* @expectedException \MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException \MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidUploadConstructorOptions
*/
public
function
testUploadConstructorOptionTypeChecks
(
array
$options
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment