return (new ChangelogDefinition()) ->
setTitle($this->
parseMetadata($content, 'title'
) ?: ''
) ->
setIssue($this->
parseMetadata($content, 'issue'
) ?: ''
) ->
setFlag($this->
parseMetadata($content, 'flag'
)) ->
setAuthor($this->
parseMetadata($content, 'author'
)) ->
setAuthorEmail($this->
parseMetadata($content, 'author_email'
)) ->
setAuthorGitHub($this->
parseMetadata($content, 'author_github'
)) ->
setCore($this->
parseSection($content, ChangelogSection::core->value
)) ->
setAdministration($this->
parseSection($content, ChangelogSection::administration->value
)) ->
setStorefront($this->
parseSection($content, ChangelogSection::storefront->value
)) ->
setApi($this->
parseSection($content, ChangelogSection::api->value
)) ->
setUpgradeInformation($this->
parseSection($content, ChangelogSection::upgrade->value
)) ->
setNextMajorVersionChanges($this->
parseSection($content, ChangelogSection::major->value
));
} /**
* Retrieve the metadata of changelog
*/
private function parseMetadata(string
$content, string
$meta): ?string
{ preg_match('/^' .
$meta . '\s*:([^\n]+)$/im',
$content,
$matches);