Book
in package
Book entity representing a collection of related texts (chapters).
Books group multiple texts together, typically from EPUB imports or large text imports that were automatically split into chapters.
Tags
Table of Contents
Properties
- $author : string|null
- $coverPath : string|null
- $createdAt : string|null
- $currentChapter : int
- $description : string|null
- $id : int|null
- $languageId : int
- $sourceHash : string|null
- $sourceType : string
- $title : string
- $totalChapters : int
- $updatedAt : string|null
- $userId : int|null
Methods
- author() : string|null
- changeLanguage() : void
- Change the language for this book.
- coverPath() : string|null
- create() : self
- Create a new book.
- createdAt() : string|null
- currentChapter() : int
- description() : string|null
- fromDbRecord() : self
- Load from a database record.
- getProgressPercent() : float
- Get the reading progress as a percentage.
- id() : int|null
- isCompleted() : bool
- Check if the book has been fully read.
- isNew() : bool
- Check if this is a new (unsaved) book.
- languageId() : int
- rename() : void
- Update the book title.
- setAuthor() : void
- Update the book author.
- setCoverPath() : void
- Set the cover image path.
- setCurrentChapter() : void
- Update the current reading position.
- setDescription() : void
- Update the book description.
- setTotalChapters() : void
- Update the total chapter count.
- sourceHash() : string|null
- sourceType() : string
- title() : string
- totalChapters() : int
- updatedAt() : string|null
- userId() : int|null
- __construct() : mixed
- Private constructor - use factory methods instead.
Properties
$author
private
string|null
$author
$coverPath
private
string|null
$coverPath
$createdAt
private
string|null
$createdAt
$currentChapter
private
int
$currentChapter
$description
private
string|null
$description
$id
private
int|null
$id
$languageId
private
int
$languageId
$sourceHash
private
string|null
$sourceHash
$sourceType
private
string
$sourceType
$title
private
string
$title
$totalChapters
private
int
$totalChapters
$updatedAt
private
string|null
$updatedAt
$userId
private
int|null
$userId
Methods
author()
public
author() : string|null
Return values
string|nullchangeLanguage()
Change the language for this book.
public
changeLanguage(int $languageId) : void
Parameters
- $languageId : int
-
New language ID
Tags
coverPath()
public
coverPath() : string|null
Return values
string|nullcreate()
Create a new book.
public
static create(int $languageId, string $title[, string|null $author = null ][, string|null $description = null ][, string $sourceType = 'text' ][, string|null $sourceHash = null ][, int|null $userId = null ]) : self
Parameters
- $languageId : int
-
Language ID for this book
- $title : string
-
Book title
- $author : string|null = null
-
Author name
- $description : string|null = null
-
Book description
- $sourceType : string = 'text'
-
Source type: 'text', 'epub', or 'pdf'
- $sourceHash : string|null = null
-
SHA-256 hash for duplicate detection
- $userId : int|null = null
-
User ID (for multi-user mode)
Tags
Return values
selfcreatedAt()
public
createdAt() : string|null
Return values
string|nullcurrentChapter()
public
currentChapter() : int
Return values
intdescription()
public
description() : string|null
Return values
string|nullfromDbRecord()
Load from a database record.
public
static fromDbRecord(array<string, mixed> $record) : self
Parameters
- $record : array<string, mixed>
-
Database record
Return values
selfgetProgressPercent()
Get the reading progress as a percentage.
public
getProgressPercent() : float
Return values
float —Progress from 0.0 to 100.0
id()
public
id() : int|null
Return values
int|nullisCompleted()
Check if the book has been fully read.
public
isCompleted() : bool
Return values
boolisNew()
Check if this is a new (unsaved) book.
public
isNew() : bool
Return values
boollanguageId()
public
languageId() : int
Return values
intrename()
Update the book title.
public
rename(string $title) : void
Parameters
- $title : string
-
The new title
Tags
setAuthor()
Update the book author.
public
setAuthor(string|null $author) : void
Parameters
- $author : string|null
-
The new author name
setCoverPath()
Set the cover image path.
public
setCoverPath(string|null $path) : void
Parameters
- $path : string|null
-
Path to the cover image
setCurrentChapter()
Update the current reading position.
public
setCurrentChapter(int $chapterNum) : void
Parameters
- $chapterNum : int
-
Chapter number (1-based)
Tags
setDescription()
Update the book description.
public
setDescription(string|null $description) : void
Parameters
- $description : string|null
-
The new description
setTotalChapters()
Update the total chapter count.
public
setTotalChapters(int $count) : void
Parameters
- $count : int
-
Number of chapters
Tags
sourceHash()
public
sourceHash() : string|null
Return values
string|nullsourceType()
public
sourceType() : string
Return values
stringtitle()
public
title() : string
Return values
stringtotalChapters()
public
totalChapters() : int
Return values
intupdatedAt()
public
updatedAt() : string|null
Return values
string|nulluserId()
public
userId() : int|null
Return values
int|null__construct()
Private constructor - use factory methods instead.
private
__construct(int|null $id, int|null $userId, int $languageId, string $title, string|null $author, string|null $description, string|null $coverPath, string $sourceType, string|null $sourceHash, int $totalChapters, int $currentChapter[, string|null $createdAt = null ][, string|null $updatedAt = null ]) : mixed
Parameters
- $id : int|null
- $userId : int|null
- $languageId : int
- $title : string
- $author : string|null
- $description : string|null
- $coverPath : string|null
- $sourceType : string
- $sourceHash : string|null
- $totalChapters : int
- $currentChapter : int
- $createdAt : string|null = null
- $updatedAt : string|null = null