Skip to content

Commit

Permalink
Merge pull request #397 from ergebnis/fix/rename
Browse files Browse the repository at this point in the history
Fix: Rename constructor
  • Loading branch information
localheinz committed Jun 26, 2023
2 parents 3826b7e + 7b459f7 commit aa93ad5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ For a full diff see [`2.1.0...main`][2.1.0...main].
### Changed

- Dropped support for PHP 8.0 ([#393]), by [@localheinz]
- Renamed `Parsed::fromFrontMatterAndContent()` to `Parsed::create()` ([#397]), by [@localheinz]

## [`2.1.0`][2.1.0]

Expand Down Expand Up @@ -100,5 +101,6 @@ For a full diff see [`4e97e14...0.1.0`][4e97e14...0.1.0].
[#344]: https://github.com/ergebnis/front-matter/pull/344
[#346]: https://github.com/ergebnis/front-matter/pull/346
[#393]: https://github.com/ergebnis/front-matter/pull/393
[#397]: https://github.com/ergebnis/front-matter/pull/397

[@localheinz]: https://github.com/localheinz
2 changes: 1 addition & 1 deletion src/Parsed.php
Expand Up @@ -24,7 +24,7 @@ private function __construct(
) {
}

public static function fromFrontMatterAndContent(
public static function create(
FrontMatter $frontMatter,
Content $content,
): self {
Expand Down
6 changes: 3 additions & 3 deletions src/YamlParser.php
Expand Up @@ -28,7 +28,7 @@ public function hasFrontMatter(string $value): bool
public function parse(string $value): Parsed
{
if (\preg_match(self::PATTERN, $value, $matches) !== 1) {
return Parsed::fromFrontMatterAndContent(
return Parsed::create(
FrontMatter::fromArray([]),
Content::fromString($value),
);
Expand All @@ -39,7 +39,7 @@ public function parse(string $value): Parsed
$rawFrontMatter = $matches['frontMatter'];

if ('' === $rawFrontMatter) {
return Parsed::fromFrontMatterAndContent(
return Parsed::create(
FrontMatter::fromArray([]),
$content,
);
Expand All @@ -61,7 +61,7 @@ public function parse(string $value): Parsed
throw Exception\FrontMatterIsNotAnObject::create();
}

return Parsed::fromFrontMatterAndContent(
return Parsed::create(
$frontMatter,
$content,
);
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/ParsedTest.php
Expand Up @@ -26,7 +26,7 @@ final class ParsedTest extends Framework\TestCase
{
use Test\Util\Helper;

public function testFromFrontMatterAndContentReturnsParsed(): void
public function testCreateReturnsParsed(): void
{
$faker = self::faker();

Expand All @@ -38,7 +38,7 @@ public function testFromFrontMatterAndContentReturnsParsed(): void

$content = Content::fromString($faker->realText());

$parsed = Parsed::fromFrontMatterAndContent(
$parsed = Parsed::create(
$frontMatter,
$content,
);
Expand Down

0 comments on commit aa93ad5

Please sign in to comment.