Skip to content

Commit

Permalink
Fix calculated end chapter number for books with prologues
Browse files Browse the repository at this point in the history
  • Loading branch information
TechWilk committed Nov 13, 2024
1 parent 60cb795 commit 67d2fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BiblePassageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function parse(string $versesString): array

if (1 === count($splitSection)) {
$endBookObject = $this->getBookFromAbbreviation($lastBook);
$endChapterForReference = (int) ($lastChapter ?? $endBookObject->chaptersInBook());
$endChapterForReference = (int) ($lastChapter ?? array_key_last($endBookObject->chapterStructure()));
$toReference = new BibleReference(
$endBookObject,
$endChapterForReference,
Expand Down
6 changes: 6 additions & 0 deletions tests/ParserCatholicStructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@ public function providerVerses(): array
['Sirach 0:1', 'Sirach 0:1'],
],
],
// 'sirach whole book including prologue' => [
// 'Sirach',
// [
// ['Sirach 0:1', 'Sirach 51:30'],
// ],
// ],
];
}

Expand Down

0 comments on commit 67d2fe1

Please sign in to comment.