From 67d2fe1f459313c30cc11806ea728510505da2dc Mon Sep 17 00:00:00 2001 From: Christopher Wilkinson Date: Wed, 13 Nov 2024 19:59:45 +0000 Subject: [PATCH] Fix calculated end chapter number for books with prologues --- src/BiblePassageParser.php | 2 +- tests/ParserCatholicStructureTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BiblePassageParser.php b/src/BiblePassageParser.php index f56ab10..1c1593d 100644 --- a/src/BiblePassageParser.php +++ b/src/BiblePassageParser.php @@ -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, diff --git a/tests/ParserCatholicStructureTest.php b/tests/ParserCatholicStructureTest.php index c535e7b..2f6a49a 100644 --- a/tests/ParserCatholicStructureTest.php +++ b/tests/ParserCatholicStructureTest.php @@ -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'], + // ], + // ], ]; }