GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 140efb...0e1ebf )
by Sebastian
01:14
created

YamlFrontMatter::parseFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spatie\YamlFrontMatter;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
class YamlFrontMatter
8
{
9
    public static function parse(string $content): Document
10
    {
11
        $pattern = '/[\s\r\n]---[\s\r\n]/s';
12
13
        $parts = preg_split($pattern, PHP_EOL . ltrim($content));
14
15
        if (count($parts) < 3) {
16
            return new Document([], $content);
17
        }
18
19
        $matter = Yaml::parse(trim($parts[1]));
20
21
        $body = implode(PHP_EOL . "---" . PHP_EOL, array_slice($parts, 2));
22
23
        return new Document($matter, $body);
24
    }
25
26
    public static function parseFile(string $path): Document
27
    {
28
        return static::parse(
29
            file_get_contents($path)
30
        );
31
    }
32
}
33