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
48b3de1c
Commit
48b3de1c
authored
Apr 23, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-75: Refactor model classes and add class-level docs
parent
2f63218a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
CollectionInfo.php
src/Model/CollectionInfo.php
+18
-9
DatabaseInfo.php
src/Model/DatabaseInfo.php
+15
-9
No files found.
src/Model/CollectionInfo.php
View file @
48b3de1c
...
...
@@ -2,10 +2,20 @@
namespace
MongoDB\Model
;
/**
* Collection information model class.
*
* This class models the collection information returned by the listCollections
* command or, for legacy servers, queries on the "system.namespaces"
* collection. It provides methods to access options for the collection.
*
* @api
* @see MongoDB\Database::listCollections()
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst
*/
class
CollectionInfo
{
private
$name
;
private
$options
;
private
$info
;
/**
* Constructor.
...
...
@@ -14,8 +24,7 @@ class CollectionInfo
*/
public
function
__construct
(
array
$info
)
{
$this
->
name
=
(
string
)
$info
[
'name'
];
$this
->
options
=
isset
(
$info
[
'options'
])
?
(
array
)
$info
[
'options'
]
:
array
();
$this
->
info
=
$info
;
}
/**
...
...
@@ -25,7 +34,7 @@ class CollectionInfo
*/
public
function
getName
()
{
return
$this
->
name
;
return
(
string
)
$this
->
info
[
'name'
]
;
}
/**
...
...
@@ -35,7 +44,7 @@ class CollectionInfo
*/
public
function
getOptions
()
{
return
$this
->
options
;
return
isset
(
$this
->
info
[
'options'
])
?
(
array
)
$this
->
info
[
'options'
]
:
array
()
;
}
/**
...
...
@@ -45,7 +54,7 @@ class CollectionInfo
*/
public
function
isCapped
()
{
return
isset
(
$this
->
options
[
'capped'
])
?
(
boolean
)
$this
->
options
[
'capped'
]
:
false
;
return
!
empty
(
$this
->
info
[
'options'
][
'capped'
])
;
}
/**
...
...
@@ -55,7 +64,7 @@ class CollectionInfo
*/
public
function
getCappedMax
()
{
return
isset
(
$this
->
options
[
'max'
])
?
(
integer
)
$this
->
options
[
'max'
]
:
null
;
return
isset
(
$this
->
info
[
'options'
][
'max'
])
?
(
integer
)
$this
->
info
[
'options'
]
[
'max'
]
:
null
;
}
/**
...
...
@@ -65,6 +74,6 @@ class CollectionInfo
*/
public
function
getCappedSize
()
{
return
isset
(
$this
->
options
[
'size'
])
?
(
integer
)
$this
->
options
[
'size'
]
:
null
;
return
isset
(
$this
->
info
[
'options'
][
'size'
])
?
(
integer
)
$this
->
info
[
'options'
]
[
'size'
]
:
null
;
}
}
src/Model/DatabaseInfo.php
View file @
48b3de1c
...
...
@@ -2,11 +2,19 @@
namespace
MongoDB\Model
;
/**
* Database information model class.
*
* This class models the database information returned by the listDatabases
* command. It provides methods to access common database properties.
*
* @api
* @see MongoDB\Client::listDatabases()
* @see http://docs.mongodb.org/manual/reference/command/listDatabases/
*/
class
DatabaseInfo
{
private
$empty
;
private
$name
;
private
$sizeOnDisk
;
private
$info
;
/**
* Constructor.
...
...
@@ -15,9 +23,7 @@ class DatabaseInfo
*/
public
function
__construct
(
array
$info
)
{
$this
->
name
=
(
string
)
$info
[
'name'
];
$this
->
empty
=
(
boolean
)
$info
[
'empty'
];
$this
->
sizeOnDisk
=
(
integer
)
$info
[
'sizeOnDisk'
];
$this
->
info
=
$info
;
}
/**
...
...
@@ -27,7 +33,7 @@ class DatabaseInfo
*/
public
function
getName
()
{
return
$this
->
name
;
return
(
string
)
$this
->
info
[
'name'
]
;
}
/**
...
...
@@ -37,7 +43,7 @@ class DatabaseInfo
*/
public
function
getSizeOnDisk
()
{
return
$this
->
sizeOnDisk
;
return
(
integer
)
$this
->
info
[
'sizeOnDisk'
]
;
}
/**
...
...
@@ -47,6 +53,6 @@ class DatabaseInfo
*/
public
function
isEmpty
()
{
return
$this
->
empty
;
return
(
boolean
)
$this
->
info
[
'empty'
]
;
}
}
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