Foxtrott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172579

Change subject: Refactor MenuFromLines::parseOneLine
......................................................................

Refactor MenuFromLines::parseOneLine

Change-Id: Id02df2c7db397bb63f07ca6c4ea880ff70f190f8
---
M src/Menu/MenuFromLines.php
1 file changed, 21 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/chameleon 
refs/changes/79/172579/1

diff --git a/src/Menu/MenuFromLines.php b/src/Menu/MenuFromLines.php
index ff03401..f070b10 100644
--- a/src/Menu/MenuFromLines.php
+++ b/src/Menu/MenuFromLines.php
@@ -137,16 +137,8 @@
                        return null;
                }
 
-               list( $depth, $line ) = $this->extractDepthAndLine( $rawLine );
-
-               $lineArr = array_map( 'trim', explode( '|', $line, 2 ) );
-
-               $linkTarget = trim( trim( $lineArr[ 0 ], '[]' ) );
-               $linkTarget = $this->getTextFromMessageName( $linkTarget );
-               $href = $this->getHrefForTarget( $linkTarget );
-
-               $linkDescription = count( $lineArr ) > 1 ? $lineArr[ 1 ] : '';
-               $text = $linkDescription === '' ? $linkTarget : 
$this->getTextFromMessageName( $linkDescription );
+               list( $depth, $linkDescription ) = $this->extractDepthAndLine( 
$rawLine );
+               list( $href, $text ) = $this->extractHrefAndLinkText( 
$linkDescription );
 
                return array(
                        'text'  => $text,
@@ -172,6 +164,25 @@
        }
 
        /**
+        * @param $linkDescription
+        *
+        * @return array
+        */
+       protected function extractHrefAndLinkText( $linkDescription ) {
+               
+               $linkAttributes = array_map( 'trim', explode( '|', 
$linkDescription, 2 ) );
+
+               $linkTarget = trim( trim( $linkAttributes[ 0 ], '[]' ) );
+               $linkTarget = $this->getTextFromMessageName( $linkTarget );
+               $href = $this->getHrefForTarget( $linkTarget );
+
+               $linkDescription = count( $linkAttributes ) > 1 ? 
$linkAttributes[ 1 ] : '';
+               $text = $linkDescription === '' ? $linkTarget : 
$this->getTextFromMessageName( $linkDescription );
+
+               return array( $href, $text );
+       }
+
+       /**
         * @param string $messageName
         *
         * @return string

-- 
To view, visit https://gerrit.wikimedia.org/r/172579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id02df2c7db397bb63f07ca6c4ea880ff70f190f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to