Commit bc65629c authored by Jeremy Mikola's avatar Jeremy Mikola

Replace private methods with generate_index_name() function

parent 3028dfde
...@@ -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->generateName($index['key']); $index['name'] = \MongoDB\generate_index_name($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;
}
} }
...@@ -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->generateIndexName($options['hint']); $options['hint'] = \MongoDB\generate_index_name($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;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment