Merge "Revert "Remove old compat methods/functions for mb_ functions""
[lhc/web/wiklou.git] / languages / Language.php
index b36732b..9f00d04 100644 (file)
@@ -245,6 +245,17 @@ class Language {
         * @return bool
         */
        public static function isValidBuiltInCode( $code ) {
+
+               if( !is_string($code) ) {
+                       $type = gettype( $code );
+                       if( $type === 'object' ) {
+                               $addmsg = " of class " . get_class( $code );
+                       } else {
+                               $addmsg = '';
+                       }
+                       throw new MWException( __METHOD__ . " must be passed a string, $type given$addmsg" );
+               }
+
                return preg_match( '/^[a-z0-9-]+$/i', $code );
        }
 
@@ -2707,12 +2718,26 @@ class Language {
        }
 
        /**
-        * An arrow, depending on the language direction
+        * An arrow, depending on the language direction.
         *
+        * @param $direction String: the direction of the arrow: forwards (default), backwards, left, right, up, down.
         * @return string
         */
-       function getArrow() {
-               return $this->isRTL() ? '←' : '→';
+       function getArrow( $direction = 'forwards' ) {
+               switch ( $direction ) {
+               case 'forwards':
+                       return $this->isRTL() ? '←' : '→';
+               case 'backwards':
+                       return $this->isRTL() ? '→' : '←';
+               case 'left':
+                       return '←';
+               case 'right':
+                       return '→';
+               case 'up':
+                       return '↑';
+               case 'down':
+                       return '↓';
+               }
        }
 
        /**