src/Hpkns/FrontMatter/Parser.php
public function parse($fm, array $default = [])
    {
        $pieces = [];
        $parsed = [];
        $regexp = '/^-{3}(?:\n|\r)(.+?)-{3}(.*)$/ms';

        if(preg_match($regexp, $fm, $pieces) && $yaml = $pieces[1])
        {
            $parsed = $this->yaml->parse($yaml, true);

            if(is_array($parsed))
            {
                $parsed['content'] = trim($pieces[2]);
                return $this->fillDefault($parsed, $default);
            }
        }

        throw new Exceptions\FrontMatterHeaderNotFoundException('Parser failed to find a proper Front Matter header');
    }
public function parse($fm, array $default = [])
    {
        $pieces = [];
        $parsed = [];
        $regexp = '/^-{3}(?:\n|\r)(.+?)-{3}(.*)$/ms';

        if(preg_match($regexp, $fm, $pieces) && $yaml = $pieces[1])
        {
            $parsed = $this->yaml->parse($yaml, true);

            if(is_array($parsed))
            {
                $parsed['content'] = trim($pieces[2]);
                return $this->fillDefault($parsed, $default);
            }
        }

        throw new Exceptions\FrontMatterHeaderNotFoundException('Parser failed to find a proper Front Matter header');
    }
public function parse ( $ fm , array $ default = [ ] ) { $ pieces = [ ] ; $ parsed = [ ] ; $ regexp = '/^-{3}(?:\n|\r)(.+?)-{3}(.*)$/ms' ; if ( preg_match ( $ regexp , $ fm , $ pieces ) && $ yaml = $ pieces [ 1 ] ) { $ parsed = $ this -> yaml -> parse ( $ yaml , true ) ; if ( is_array ( $ parsed ) ) { $ parsed [ 'content' ] = trim ( $ pieces [ 2 ] ) ; return $ this -> fillDefault ( $ parsed , $ default ) ; } } throw new Exceptions \ FrontMatterHeaderNotFoundException ( 'Parser failed to find a proper Front Matter header' ) ; }
Parse a front matter file and return an array with its content

@param  string $fm
@param  array  $default
@return array
Parse a front matter file and return an array with its content