Documentation

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
category

Lwt

author

HugoFara hugo.farajallah@protonmail.com

license

Unlicense http://unlicense.org/

link
https://hugofara.github.io/lwt/docs/php/
since
3.0.0

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|null

changeLanguage()

Change the language for this book.

public changeLanguage(int $languageId) : void
Parameters
$languageId : int

New language ID

Tags
throws
InvalidArgumentException

If language ID is invalid

coverPath()

public coverPath() : string|null
Return values
string|null

create()

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
throws
InvalidArgumentException

If title is empty or sourceType is invalid

Return values
self

createdAt()

public createdAt() : string|null
Return values
string|null

currentChapter()

public currentChapter() : int
Return values
int

description()

public description() : string|null
Return values
string|null

fromDbRecord()

Load from a database record.

public static fromDbRecord(array<string, mixed> $record) : self
Parameters
$record : array<string, mixed>

Database record

Return values
self

getProgressPercent()

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|null

isCompleted()

Check if the book has been fully read.

public isCompleted() : bool
Return values
bool

isNew()

Check if this is a new (unsaved) book.

public isNew() : bool
Return values
bool

languageId()

public languageId() : int
Return values
int

rename()

Update the book title.

public rename(string $title) : void
Parameters
$title : string

The new title

Tags
throws
InvalidArgumentException

If title is empty or too long

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
throws
InvalidArgumentException

If chapter number is invalid

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
throws
InvalidArgumentException

If count is negative

sourceHash()

public sourceHash() : string|null
Return values
string|null

sourceType()

public sourceType() : string
Return values
string

title()

public title() : string
Return values
string

totalChapters()

public totalChapters() : int
Return values
int

updatedAt()

public updatedAt() : string|null
Return values
string|null

userId()

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

        
On this page

Search results