for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Lichtenwallner (https://lichtenwallner.at)
*
* @see https://github.com/jolicht/markdown-cms for the canonical source repository
* @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
* @copyright Copyright (c) Johannes Lichtenwallner
*/
declare(strict_types = 1);
namespace Jolicht\MarkdownCms\Markdown;
use Mni\FrontYAML\Parser;
class MarkdownDocumentParser
{
* Front yaml parser
* @var Parser
private $frontYamlParser;
* Constructor
* @param Parser $frontYamlParser
public function __construct(Parser $frontYamlParser)
$this->frontYamlParser = $frontYamlParser;
}
* Get front yaml parser
* @return Parser
public function getFrontYamlParser() : Parser
return $this->frontYamlParser;
* Parse markdown string
* @param string $markdown
* @return MarkdownDocument
public function __invoke(string $markdown) : MarkdownDocument
$frontYamlDoc = $this->getFrontYamlParser()->parse($markdown);
return new MarkdownDocument($frontYamlDoc->getYAML(), $frontYamlDoc->getContent());