4
0

update 2023-06-22 08:54:55

This commit is contained in:
Robot 2023-06-22 08:54:55 +02:00
parent a1c3b7aacb
commit fa79d503ad
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
3 changed files with 113 additions and 0 deletions

View File

@ -23,6 +23,8 @@ class Watcher << (F,LightGreen) >> #Green {
# ?object $verse
+ __construct(Load $load, Insert $insert, ...)
+ api(string $translation, int $book, ...) : bool
+ next(string $translation, int $book, ...) : ?int
+ previous(int $chapter) : ?int
- translation(string $translation) : ?string
- book(string $translation, int $book) : ?string
- chapter(string $translation, int $book, ...) : ?string
@ -61,6 +63,25 @@ note left of Watcher::api
int $chapter
end note
note right of Watcher::next
Get the next chapter
since: 2.0.1
return: ?int
arguments:
string $translation
int $book
int $chapter
end note
note left of Watcher::previous
Get the previous chapter
since: 2.0.1
return: ?int
end note
note right of Watcher::translation
Get Translation Hash Value

View File

@ -200,6 +200,52 @@ final class Watcher
return false;
}
/**
* Get the next chapter
*
* @param string $translation The translation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return int|null Number if there is a next, else null
* @since 2.0.1
*/
public function next(string $translation, int $book, int $chapter): ?int
{
// we load the next chapter
$next = $chapter + 1;
// check if this books has this next chapter
if (!$this->fresh && ($chapter_sha = $this->load->value(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next],
'sha', 'chapter'
)) !== null)
{
return $next;
}
return null;
}
/**
* Get the previous chapter
*
* @param int $chapter The chapter number.
*
* @return int|null Number if there is a previous, else null
* @since 2.0.1
*/
public function previous(int $chapter): ?int
{
// we load the previous chapter
$previous = $chapter - 1;
if (!$this->fresh && $previous > 0)
{
return $previous;
}
return null;
}
/**
* Get Translation Hash Value
*

View File

@ -169,6 +169,52 @@
return false;
}
/**
* Get the next chapter
*
* @param string $translation The translation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return int|null Number if there is a next, else null
* @since 2.0.1
*/
public function next(string $translation, int $book, int $chapter): ?int
{
// we load the next chapter
$next = $chapter + 1;
// check if this books has this next chapter
if (!$this->fresh && ($chapter_sha = $this->load->value(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next],
'sha', 'chapter'
)) !== null)
{
return $next;
}
return null;
}
/**
* Get the previous chapter
*
* @param int $chapter The chapter number.
*
* @return int|null Number if there is a previous, else null
* @since 2.0.1
*/
public function previous(int $chapter): ?int
{
// we load the previous chapter
$previous = $chapter - 1;
if (!$this->fresh && $previous > 0)
{
return $previous;
}
return null;
}
/**
* Get Translation Hash Value
*