Skip to content

Commit 0113454

Browse files
authored
Merge pull request #8 from Rareloop/support-php-82
Support PHP 8.2
2 parents 17f70d6 + 69406d4 commit 0113454

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php_version: ["7.4", "8.0", "8.1"]
10+
php_version: ["8.0", "8.1", "8.2"]
1111
composer_flags: ["", "--prefer-lowest"]
1212

1313
steps:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "rareloop/primer-core",
33
"require": {
4-
"php": ">=7.4",
4+
"php": ">=8.0",
55
"symfony/finder": "^4.2.5|^5.0",
66
"twig/twig": "^2.6",
77
"illuminate/collections": "^8.53.1||^9.0.0",
88
"league/commonmark": "^1.5",
9-
"mnapoli/front-yaml": "^1.6"
9+
"spatie/yaml-front-matter": "^2.0"
1010
},
1111
"require-dev": {
1212
"phpunit/phpunit": "^9.0",

src/DocumentParsers/YAMLDocumentParser.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,24 @@
22

33
namespace Rareloop\Primer\DocumentParsers;
44

5-
use Mni\FrontYAML\Parser;
65
use Rareloop\Primer\Contracts\DocumentParser;
76
use Rareloop\Primer\Document;
87
use Spatie\YamlFrontMatter\YamlFrontMatter;
98

109
class YAMLDocumentParser implements DocumentParser
1110
{
12-
public function parse(Document $document) : Document
11+
public function parse(Document $document): Document
1312
{
14-
$parser = new Parser;
15-
$parsedDocument = $parser->parse($document->content(), false);
16-
$yaml = $parsedDocument->getYAML();
13+
$parsedDocument = YamlFrontMatter::parse($document->content());
1714

18-
$newDoc = new Document($document->id(), $parsedDocument->getContent());
19-
$newDoc->setMeta($yaml ?? []);
15+
$newDoc = new Document($document->id(), $parsedDocument->body());
16+
$newDoc->setMeta($parsedDocument->matter() ?? []);
2017

21-
if (!empty($yaml['title'])) {
22-
$newDoc->setTitle($yaml['title']);
18+
if (!empty($parsedDocument->matter('title'))) {
19+
$newDoc->setTitle($parsedDocument->matter('title'));
2320
}
2421

25-
$newDoc->setDescription($yaml['description'] ?? '');
26-
22+
$newDoc->setDescription($parsedDocument->matter('description') ?? '');
2723
return $newDoc;
2824
}
2925
}

src/FileSystemPatternProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class FileSystemPatternProvider implements PatternProvider, TemplateProvider
1414
{
1515
protected $paths;
1616
protected $fileExtension;
17+
protected ?DataParser $dataParser;
1718

1819
protected $patternPaths = [];
1920

0 commit comments

Comments
 (0)