Don't special case $list only having one item
Unindent else block
Bug: 64069
Change-Id: I171a64147fe00f00ac0523ccf58fea11e800e2fd
* @return string
*/
function listToText( $list, $sort = true ) {
- $cnt = count( $list );
-
- if ( $cnt == 1 ) {
- // Enforce always returning a string
- return (string)self::arrayToString( $list[0] );
- } elseif ( $cnt == 0 ) {
+ if ( !count( $list ) ) {
return '';
- } else {
- if ( $sort ) {
- sort( $list );
- }
-
- return $this->getLanguage()
- ->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) );
}
+ if ( $sort ) {
+ sort( $list );
+ }
+
+ return $this->getLanguage()
+ ->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) );
}
/**