1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Make this pattern a bit more reusable

This commit is contained in:
Aidan Woods 2019-02-15 23:34:58 +00:00
parent 747abe7600
commit f83ee87902
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -60,13 +60,23 @@ final class Parsedown
{ {
list($Blocks, $State) = self::blocks($Lines, $State); list($Blocks, $State) = self::blocks($Lines, $State);
$StateRenderables = \array_map( return [self::stateRenderablesFrom($Blocks), $State];
/** @return StateRenderable */ }
function (Block $Block) { return $Block->stateRenderable(); },
$Blocks
);
return [$StateRenderables, $State]; /**
* @param Component[] $Components
* @return StateRenderable[]
*/
public static function stateRenderablesFrom($Components)
{
return \array_map(
/**
* @param Component $Component
* @return StateRenderable
*/
function ($Component) { return $Component->stateRenderable(); },
$Components
);
} }
/** /**
@ -160,11 +170,7 @@ final class Parsedown
*/ */
public static function line($text, State $State) public static function line($text, State $State)
{ {
return \array_map( return self::stateRenderablesFrom(self::inlines($text, $State));
/** @return StateRenderable */
function (Inline $Inline) { return $Inline->stateRenderable(); },
self::inlines($text, $State)
);
} }
/** /**