update 2023-07-13 14:31:29
This commit is contained in:
parent
06bf530db8
commit
797c64504c
@ -17,6 +17,7 @@ class Chapter << (F,LightGreen) >> #Green {
|
|||||||
# StringHelper $stringHelper
|
# StringHelper $stringHelper
|
||||||
# array $chapters
|
# array $chapters
|
||||||
# array $validVerses
|
# array $validVerses
|
||||||
|
# array $sequential
|
||||||
+ __construct(Load $load, Config $config, ...)
|
+ __construct(Load $load, Config $config, ...)
|
||||||
+ getBookName(?string $abbreviation = null, ?int $book = null, ...) : string
|
+ getBookName(?string $abbreviation = null, ?int $book = null, ...) : string
|
||||||
+ getChapterNumber(?string $abbreviation = null, ?int $book = null, ...) : string
|
+ getChapterNumber(?string $abbreviation = null, ?int $book = null, ...) : string
|
||||||
@ -45,6 +46,7 @@ class Chapter << (F,LightGreen) >> #Green {
|
|||||||
- wordNumberArrayToString(array $wordNumberArray) : string
|
- wordNumberArrayToString(array $wordNumberArray) : string
|
||||||
- buildWordArray(array $verses, array $words) : array
|
- buildWordArray(array $verses, array $words) : array
|
||||||
- wordArrayToString(array $wordArray) : string
|
- wordArrayToString(array $wordArray) : string
|
||||||
|
- isSequential(array $arr) : bool
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Chapter::__construct
|
note right of Chapter::__construct
|
||||||
@ -328,6 +330,13 @@ note left of Chapter::wordArrayToString
|
|||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of Chapter::isSequential
|
||||||
|
Check if an array values is sequential.
|
||||||
|
|
||||||
|
since: 2.0.1
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -73,6 +73,14 @@ final class Chapter
|
|||||||
*/
|
*/
|
||||||
protected array $validVerses = [];
|
protected array $validVerses = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The check if words are sequential
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
protected array $sequential = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -704,8 +712,15 @@ final class Chapter
|
|||||||
* @return bool True on success
|
* @return bool True on success
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
*/
|
*/
|
||||||
private function isValidWordNumber($verseNumber, $wordNumber): bool
|
private function isValidWordNumber(int $verseNumber, int $wordNumber): bool
|
||||||
{
|
{
|
||||||
|
// we add the next word number to check sequential selection of words
|
||||||
|
$this->sequential[$verseNumber][$wordNumber] = $wordNumber;
|
||||||
|
if (count($this->sequential[$verseNumber]) > 1 && !$this->isSequential($this->sequential[$verseNumber]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$verse_text = $this->get()->verse_text_array ?? null;
|
$verse_text = $this->get()->verse_text_array ?? null;
|
||||||
|
|
||||||
if (($verse_text = $this->processVersesArray()) === null)
|
if (($verse_text = $this->processVersesArray()) === null)
|
||||||
@ -856,6 +871,7 @@ final class Chapter
|
|||||||
{
|
{
|
||||||
$array = array_map('trim', explode('-', $str));
|
$array = array_map('trim', explode('-', $str));
|
||||||
sort($array);
|
sort($array);
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -970,5 +986,27 @@ final class Chapter
|
|||||||
|
|
||||||
return implode(' ', $word_number);
|
return implode(' ', $word_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an array values is sequential.
|
||||||
|
*
|
||||||
|
* @param array $arr The number array.
|
||||||
|
*
|
||||||
|
* @return bool true if sequential
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
private function isSequential(array $arr): bool
|
||||||
|
{
|
||||||
|
$arr = array_values($arr); // Reset keys
|
||||||
|
for ($i = 0, $len = count($arr) - 1; $i < $len; $i++)
|
||||||
|
{
|
||||||
|
if ($arr[$i] + 1 !== $arr[$i + 1])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,14 @@
|
|||||||
*/
|
*/
|
||||||
protected array $validVerses = [];
|
protected array $validVerses = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The check if words are sequential
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
protected array $sequential = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -677,8 +685,15 @@
|
|||||||
* @return bool True on success
|
* @return bool True on success
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
*/
|
*/
|
||||||
private function isValidWordNumber($verseNumber, $wordNumber): bool
|
private function isValidWordNumber(int $verseNumber, int $wordNumber): bool
|
||||||
{
|
{
|
||||||
|
// we add the next word number to check sequential selection of words
|
||||||
|
$this->sequential[$verseNumber][$wordNumber] = $wordNumber;
|
||||||
|
if (count($this->sequential[$verseNumber]) > 1 && !$this->isSequential($this->sequential[$verseNumber]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$verse_text = $this->get()->verse_text_array ?? null;
|
$verse_text = $this->get()->verse_text_array ?? null;
|
||||||
|
|
||||||
if (($verse_text = $this->processVersesArray()) === null)
|
if (($verse_text = $this->processVersesArray()) === null)
|
||||||
@ -829,6 +844,7 @@
|
|||||||
{
|
{
|
||||||
$array = array_map('trim', explode('-', $str));
|
$array = array_map('trim', explode('-', $str));
|
||||||
sort($array);
|
sort($array);
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -943,3 +959,25 @@
|
|||||||
|
|
||||||
return implode(' ', $word_number);
|
return implode(' ', $word_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an array values is sequential.
|
||||||
|
*
|
||||||
|
* @param array $arr The number array.
|
||||||
|
*
|
||||||
|
* @return bool true if sequential
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
private function isSequential(array $arr): bool
|
||||||
|
{
|
||||||
|
$arr = array_values($arr); // Reset keys
|
||||||
|
for ($i = 0, $len = count($arr) - 1; $i < $len; $i++)
|
||||||
|
{
|
||||||
|
if ($arr[$i] + 1 !== $arr[$i + 1])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user