1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-13 16:44:36 +02:00

Flextype Core: Frontmatter Parser - removed.

This commit is contained in:
Awilum
2019-02-17 23:32:31 +03:00
parent 9c009b1316
commit 5588126967

View File

@@ -1,37 +0,0 @@
<?php
/**
* @package Flextype
*
* @author Sergey Romanenko <awilum@yandex.ru>
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
class FrontmatterParser {
/**
* Get [matter] and [body] from a content.
* PHP implementation of Jekyll Front Matter.
*
* $content = Entries::frontMatterParser($content);
*
* @param string $content Content to parse
* @access public
* @return array
*/
public static function parse(string $content) : array
{
$parts = preg_split('/^[\s\r\n]?---[\s\r\n]?$/sm', PHP_EOL . ltrim($content));
if (count($parts) < 3) {
return ['matter' => [], 'body' => $content];
}
return ['matter' => trim($parts[1]), 'body' => implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2))];
}
}