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
bca7df7f
Commit
bca7df7f
authored
Apr 25, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-63: Refactor to avoid else condition and void methods
parent
a0aceaf4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
Collection.php
src/Collection.php
+13
-11
No files found.
src/Collection.php
View file @
bca7df7f
...
@@ -312,13 +312,9 @@ class Collection
...
@@ -312,13 +312,9 @@ class Collection
$serverInfo
=
$server
->
getInfo
();
$serverInfo
=
$server
->
getInfo
();
$maxWireVersion
=
isset
(
$serverInfo
[
'maxWireVersion'
])
?
$serverInfo
[
'maxWireVersion'
]
:
0
;
$maxWireVersion
=
isset
(
$serverInfo
[
'maxWireVersion'
])
?
$serverInfo
[
'maxWireVersion'
]
:
0
;
if
(
$maxWireVersion
>=
2
)
{
return
(
$maxWireVersion
>=
2
)
$this
->
createIndexesCommand
(
$server
,
$indexes
);
?
$this
->
createIndexesCommand
(
$server
,
$indexes
)
}
else
{
:
$this
->
createIndexesLegacy
(
$server
,
$indexes
);
$this
->
createIndexesLegacy
(
$server
,
$indexes
);
}
return
array_map
(
function
(
IndexInput
$index
)
{
return
(
string
)
$index
;
},
$indexes
);
}
}
/**
/**
...
@@ -1212,8 +1208,9 @@ class Collection
...
@@ -1212,8 +1208,9 @@ class Collection
* Create one or more indexes for the collection using the createIndexes
* Create one or more indexes for the collection using the createIndexes
* command.
* command.
*
*
* @param Server $server
* @param Server $server
* @param array $indexes
* @param IndexInput[] $indexes
* @return string[] The names of the created indexes
*/
*/
private
function
createIndexesCommand
(
Server
$server
,
array
$indexes
)
private
function
createIndexesCommand
(
Server
$server
,
array
$indexes
)
{
{
...
@@ -1222,14 +1219,17 @@ class Collection
...
@@ -1222,14 +1219,17 @@ class Collection
'indexes'
=>
$indexes
,
'indexes'
=>
$indexes
,
));
));
$server
->
executeCommand
(
$this
->
dbname
,
$command
);
$server
->
executeCommand
(
$this
->
dbname
,
$command
);
return
array_map
(
function
(
IndexInput
$index
)
{
return
(
string
)
$index
;
},
$indexes
);
}
}
/**
/**
* Create one or more indexes for the collection by inserting into the
* Create one or more indexes for the collection by inserting into the
* "system.indexes" collection (MongoDB <2.6).
* "system.indexes" collection (MongoDB <2.6).
*
*
* @param Server $server
* @param Server $server
* @param array $indexes
* @param IndexInput[] $indexes
* @return string[] The names of the created indexes
*/
*/
private
function
createIndexesLegacy
(
Server
$server
,
array
$indexes
)
private
function
createIndexesLegacy
(
Server
$server
,
array
$indexes
)
{
{
...
@@ -1240,6 +1240,8 @@ class Collection
...
@@ -1240,6 +1240,8 @@ class Collection
}
}
$server
->
executeBulkWrite
(
$this
->
dbname
.
'.system.indexes'
,
$bulk
);
$server
->
executeBulkWrite
(
$this
->
dbname
.
'.system.indexes'
,
$bulk
);
return
array_map
(
function
(
IndexInput
$index
)
{
return
(
string
)
$index
;
},
$indexes
);
}
}
/**
/**
...
...
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