Xml: Simplify processing of attributes in Xml::label
authorRicordisamoa <ricordisamoa@openmailbox.org>
Wed, 10 Dec 2014 07:43:28 +0000 (07:43 +0000)
committerKrinkle <krinklemail@gmail.com>
Wed, 10 Dec 2014 19:40:03 +0000 (19:40 +0000)
Comment inserted by Antoine Musso with d86a3bc2177f79.

Also fixed wrong indentation.

Change-Id: I054762929413f90090b446c603b60ed9544c06d1

includes/Xml.php

index 159f711..c07ac73 100644 (file)
@@ -368,12 +368,10 @@ class Xml {
        public static function label( $label, $id, $attribs = array() ) {
                $a = array( 'for' => $id );
 
-               # FIXME avoid copy pasting below:
-               if ( isset( $attribs['class'] ) ) {
-                               $a['class'] = $attribs['class'];
-               }
-               if ( isset( $attribs['title'] ) ) {
-                               $a['title'] = $attribs['title'];
+               foreach ( array( 'class', 'title' ) as $attr ) {
+                       if ( isset( $attribs[$attr] ) ) {
+                               $a[$attr] = $attribs[$attr];
+                       }
                }
 
                return self::element( 'label', $a, $label );