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
bc65629c
Commit
bc65629c
authored
Jun 15, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace private methods with generate_index_name() function
parent
3028dfde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
38 deletions
+2
-38
IndexInput.php
src/Model/IndexInput.php
+1
-19
Count.php
src/Operation/Count.php
+1
-19
No files found.
src/Model/IndexInput.php
View file @
bc65629c
...
@@ -50,7 +50,7 @@ class IndexInput implements Serializable
...
@@ -50,7 +50,7 @@ class IndexInput implements Serializable
}
}
if
(
!
isset
(
$index
[
'name'
]))
{
if
(
!
isset
(
$index
[
'name'
]))
{
$index
[
'name'
]
=
$this
->
generateN
ame
(
$index
[
'key'
]);
$index
[
'name'
]
=
\MongoDB\generate_index_n
ame
(
$index
[
'key'
]);
}
}
if
(
!
is_string
(
$index
[
'name'
]))
{
if
(
!
is_string
(
$index
[
'name'
]))
{
...
@@ -80,22 +80,4 @@ class IndexInput implements Serializable
...
@@ -80,22 +80,4 @@ class IndexInput implements Serializable
{
{
return
$this
->
index
;
return
$this
->
index
;
}
}
/**
* Generates an index name from its key specification.
*
* @param array|object $key Document containing fields mapped to values,
* which denote order or an index type
* @return string
*/
private
function
generateName
(
$key
)
{
$name
=
''
;
foreach
(
$key
as
$field
=>
$type
)
{
$name
.=
(
$name
!=
''
?
'_'
:
''
)
.
$field
.
'_'
.
$type
;
}
return
$name
;
}
}
}
src/Operation/Count.php
View file @
bc65629c
...
@@ -49,7 +49,7 @@ class Count implements Executable
...
@@ -49,7 +49,7 @@ class Count implements Executable
{
{
if
(
isset
(
$options
[
'hint'
]))
{
if
(
isset
(
$options
[
'hint'
]))
{
if
(
is_array
(
$options
[
'hint'
])
||
is_object
(
$options
[
'hint'
]))
{
if
(
is_array
(
$options
[
'hint'
])
||
is_object
(
$options
[
'hint'
]))
{
$options
[
'hint'
]
=
$this
->
generateIndexN
ame
(
$options
[
'hint'
]);
$options
[
'hint'
]
=
\MongoDB\generate_index_n
ame
(
$options
[
'hint'
]);
}
}
if
(
!
is_string
(
$options
[
'hint'
]))
{
if
(
!
is_string
(
$options
[
'hint'
]))
{
...
@@ -121,22 +121,4 @@ class Count implements Executable
...
@@ -121,22 +121,4 @@ class Count implements Executable
return
new
Command
(
$cmd
);
return
new
Command
(
$cmd
);
}
}
/**
* Generates an index name from its key specification.
*
* @param array|object $key Document containing fields mapped to values,
* which denote order or an index type
* @return string
*/
private
function
generateIndexName
(
$key
)
{
$name
=
''
;
foreach
(
$key
as
$field
=>
$type
)
{
$name
.=
(
$name
!=
''
?
'_'
:
''
)
.
$field
.
'_'
.
$type
;
}
return
$name
;
}
}
}
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