profiler: Simplify code for class name mapping
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 18 Nov 2014 20:46:41 +0000 (20:46 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 18 Nov 2014 20:46:41 +0000 (20:46 +0000)
Follows-up 000c6529d. Handle errors first.

Change-Id: I70308783a2e8b140b3c850758cce36544b32eb20

includes/profiler/Profiler.php

index 0df3468..f2bdc84 100644 (file)
@@ -157,11 +157,11 @@ abstract class Profiler {
                }
 
                foreach ( $output as $outType ) {
-                       if ( isset( self::$outputTypes[$outType] ) ) {
-                               $class = self::$outputTypes[$outType];
-                       } else {
+                       if ( !isset( self::$outputTypes[$outType] ) ) {
                                throw new MWException( "'$outType' is an invalid output type" );
                        }
+                       $class = self::$outputTypes[$outType];
+
                        /** @var ProfilerOutput $profileOut */
                        $profileOut = new $class( $this, $this->params );
                        if ( $profileOut->canUse() ) {