Commit a87c55ff by pana1990 Committed by Qiang Xue

fix camelCase syntax

parent 05263692
...@@ -580,7 +580,7 @@ class BaseArrayHelper ...@@ -580,7 +580,7 @@ class BaseArrayHelper
* // output : Spain, France, and Italy * // output : Spain, France, and Italy
* *
* // working with options for change behavior * // working with options for change behavior
* \yii\helpers\ArrayHelper::sentence($array, ['last_word_connector' => ' or ']); * \yii\helpers\ArrayHelper::sentence($array, ['lastWordConnector' => ' or ']);
* // output : Spain, France or Italy * // output : Spain, France or Italy
* ~~~ * ~~~
* *
...@@ -588,13 +588,13 @@ class BaseArrayHelper ...@@ -588,13 +588,13 @@ class BaseArrayHelper
* @param array $options the options in terms of name-value pairs. The following options * @param array $options the options in terms of name-value pairs. The following options
* are specially handled: * are specially handled:
* *
* - words_connector: The sign or word used to join the elements in arrays with two or * - wordsConnector: The sign or word used to join the elements in arrays with two or
* more elements. By default ', ''. * more elements. By default ', ''.
* *
* - two_words_connector: The sign or word used to join the elements in arrays with two * - twoWordsConnector: The sign or word used to join the elements in arrays with two
* elements. By default ' and '. * elements. By default ' and '.
* *
* - last_word_connector: The sign or word used to join the last element in arrays with * - lastWordConnector: The sign or word used to join the last element in arrays with
* three or more elements. By default ', and '. * three or more elements. By default ', and '.
* *
* - locale: If i18n is available, you can set a locale and use the traslation file defined * - locale: If i18n is available, you can set a locale and use the traslation file defined
...@@ -605,9 +605,9 @@ class BaseArrayHelper ...@@ -605,9 +605,9 @@ class BaseArrayHelper
public static function sentence($array, $options = []) public static function sentence($array, $options = [])
{ {
$default_options = [ $default_options = [
'words_connector' => ', ', 'wordsConnector' => ', ',
'two_words_connector' => ' and ', 'twoWordsConnector' => ' and ',
'last_word_connector' => ', and ', 'lastWordConnector' => ', and ',
'locale' => Yii::$app->language 'locale' => Yii::$app->language
]; ];
...@@ -621,9 +621,9 @@ class BaseArrayHelper ...@@ -621,9 +621,9 @@ class BaseArrayHelper
case 1: case 1:
return $array[0]; return $array[0];
case 2: case 2:
return $array[0] . \Yii::t('yii', $options['two_words_connector'], [], $options['locale']) . $array[1]; return $array[0] . \Yii::t('yii', $options['twoWordsConnector'], [], $options['locale']) . $array[1];
default: default:
return implode($options['words_connector'], array_slice($array, 0, -1)) . \Yii::t('yii', $options['last_word_connector'], [], $options['locale']) . $array[$count - 1]; return implode($options['wordsConnector'], array_slice($array, 0, -1)) . \Yii::t('yii', $options['lastWordConnector'], [], $options['locale']) . $array[$count - 1];
} }
} }
} }
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