Skip to content

Commit 32401b1

Browse files
committed
Resolve an issue with John and 1 John. Closes #15
1 parent e20428b commit 32401b1

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/ScripturNum.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function toString($options): string
189189

190190

191191
/**
192-
* Returns a human-readable string with the settings defined in a given setting set.
192+
* Returns a human-readable string with the settings defined in a given set of settings.
193193
*
194194
* @param string|array $options The setting set to use, or an array of options.
195195
*
@@ -1001,7 +1001,12 @@ public static function extractFromString(string $string, bool $excludeAllBookOnl
10011001
$lastBook = -1;
10021002
$lastEnd = -1;
10031003
foreach ($combinedMatches as $m) {
1004-
$ints = static::stringToInts($m[0], $exceptions);
1004+
if (is_array($exceptions)) {
1005+
$ints = static::stringToInts($m[0], $exceptions);
1006+
} else {
1007+
$e = []; // functionally suppressing exceptions
1008+
$ints = static::stringToInts($m[0], $e);
1009+
}
10051010
foreach($ints as $i) {
10061011
$sn = new static($i);
10071012
if ($lastBook != $sn->book && $lastEnd > $m[1]) {

tests/ScripturNumPublicTests.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,4 +1000,27 @@ public function test_issue14b()
10001000

10011001
$this->assertCount(1, $a);
10021002
}
1003+
1004+
public function test_issue15a()
1005+
{
1006+
$a = "1 John 2:18-27";
1007+
$sn = ScripturNum::extractFromString($a);
1008+
$this->assertEquals($a, $sn->getString());
1009+
}
1010+
1011+
public function test_issue15b()
1012+
{
1013+
$a = "1 John 2:18-27";
1014+
$sn = ScripturNum::stringToInts($a);
1015+
$this->assertCount(1, $sn);
1016+
}
1017+
1018+
1019+
public function test_issue15c()
1020+
{
1021+
$a = "1 John 2:28-3:10";
1022+
$e = [];
1023+
$sn = ScripturNum::extractFromString($a, false, $e);
1024+
$this->assertEquals($a, $sn->getString());
1025+
}
10031026
}

0 commit comments

Comments
 (0)