Documentation

Term

A term (word or multi-word) represented as a rich domain object.

Terms are vocabulary items that users learn. They have a status indicating learning progress (1-5), or special statuses (98=ignored, 99=well-known).

This class enforces domain invariants and encapsulates business logic.

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

$createdAt  : DateTimeImmutable
$id  : TermId
$languageId  : LanguageId
$lemma  : string|null
$lemmaLc  : string|null
$notes  : string
$random  : float
$romanization  : string
$sentence  : string
$status  : TermStatus
$statusChangedAt  : DateTimeImmutable
$text  : string
$textLowercase  : string
$todayScore  : float
$tomorrowScore  : float
$translation  : string
$wordCount  : int

Methods

advanceStatus()  : void
Advance the term's status to the next learning stage.
create()  : self
Create a new term.
createdAt()  : DateTimeImmutable
decreaseStatus()  : void
Decrease the term's status to the previous learning stage.
hasTranslation()  : bool
Check if the term has a translation.
id()  : TermId
ignore()  : void
Mark the term as ignored.
isIgnored()  : bool
Check if the term is ignored.
isKnown()  : bool
Check if the term is known (learned or well-known).
isLearning()  : bool
Check if the term is in a learning stage.
isMultiWord()  : bool
Check if this is a multi-word term.
languageId()  : LanguageId
lemma()  : string|null
lemmaLc()  : string|null
markAsLearned()  : void
Mark the term as fully learned.
markAsWellKnown()  : void
Mark the term as well-known.
needsReview()  : bool
Check if the term needs review.
notes()  : string
random()  : float
romanization()  : string
sentence()  : string
setStatus()  : void
Set the term's status to a specific value.
status()  : TermStatus
statusChangedAt()  : DateTimeImmutable
text()  : string
textLowercase()  : string
todayScore()  : float
tomorrowScore()  : float
translation()  : string
updateLemma()  : void
Update the lemma (base form).
updateNotes()  : void
Update the notes.
updateRomanization()  : void
Update the romanization.
updateScores()  : void
Update review scores.
updateSentence()  : void
Update the example sentence.
updateTranslation()  : void
Update the translation.
wordCount()  : int
__construct()  : mixed
Private constructor - use factory methods instead.
calculateWordCount()  : int
Calculate word count for a text.

Properties

$createdAt

private DateTimeImmutable $createdAt

$lemma

private string|null $lemma = null

$lemmaLc

private string|null $lemmaLc = null

$notes

private string $notes

$random

private float $random

$romanization

private string $romanization

$sentence

private string $sentence

$statusChangedAt

private DateTimeImmutable $statusChangedAt

$text

private string $text

$textLowercase

private string $textLowercase

$todayScore

private float $todayScore

$tomorrowScore

private float $tomorrowScore

$translation

private string $translation

$wordCount

private int $wordCount

Methods

advanceStatus()

Advance the term's status to the next learning stage.

public advanceStatus() : void

create()

Create a new term.

public static create(LanguageId $languageId, string $text[, string $translation = '' ]) : self
Parameters
$languageId : LanguageId

The language this term belongs to

$text : string

The term text

$translation : string = ''

Optional initial translation

Tags
throws
InvalidArgumentException

If text is empty

Return values
self

createdAt()

public createdAt() : DateTimeImmutable
Return values
DateTimeImmutable

decreaseStatus()

Decrease the term's status to the previous learning stage.

public decreaseStatus() : void

hasTranslation()

Check if the term has a translation.

public hasTranslation() : bool
Return values
bool

ignore()

Mark the term as ignored.

public ignore() : void

isIgnored()

Check if the term is ignored.

public isIgnored() : bool
Return values
bool

isKnown()

Check if the term is known (learned or well-known).

public isKnown() : bool
Return values
bool

isLearning()

Check if the term is in a learning stage.

public isLearning() : bool
Return values
bool

isMultiWord()

Check if this is a multi-word term.

public isMultiWord() : bool
Return values
bool

lemma()

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

lemmaLc()

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

markAsLearned()

Mark the term as fully learned.

public markAsLearned() : void

markAsWellKnown()

Mark the term as well-known.

public markAsWellKnown() : void

needsReview()

Check if the term needs review.

public needsReview() : bool
Return values
bool

notes()

public notes() : string
Return values
string

random()

public random() : float
Return values
float

romanization()

public romanization() : string
Return values
string

sentence()

public sentence() : string
Return values
string

setStatus()

Set the term's status to a specific value.

public setStatus(TermStatus $status) : void
Parameters
$status : TermStatus

The new status

statusChangedAt()

public statusChangedAt() : DateTimeImmutable
Return values
DateTimeImmutable

text()

public text() : string
Return values
string

textLowercase()

public textLowercase() : string
Return values
string

todayScore()

public todayScore() : float
Return values
float

tomorrowScore()

public tomorrowScore() : float
Return values
float

translation()

public translation() : string
Return values
string

updateLemma()

Update the lemma (base form).

public updateLemma(string|null $lemma) : void
Parameters
$lemma : string|null

The new lemma, or null to clear

updateNotes()

Update the notes.

public updateNotes(string $notes) : void
Parameters
$notes : string

The new notes

updateRomanization()

Update the romanization.

public updateRomanization(string $romanization) : void
Parameters
$romanization : string

The new romanization

updateScores()

Update review scores.

public updateScores(float $todayScore, float $tomorrowScore) : void
Parameters
$todayScore : float

Today's score

$tomorrowScore : float

Tomorrow's score

updateSentence()

Update the example sentence.

public updateSentence(string $sentence) : void
Parameters
$sentence : string

The new sentence

updateTranslation()

Update the translation.

public updateTranslation(string $translation) : void
Parameters
$translation : string

The new translation

wordCount()

public wordCount() : int
Return values
int

__construct()

Private constructor - use factory methods instead.

private __construct(TermId $id, LanguageId $languageId, string $text, string $textLowercase, string|null $lemma, string|null $lemmaLc, TermStatus $status, string $translation, string $sentence, string $notes, string $romanization, int $wordCount, DateTimeImmutable $createdAt, DateTimeImmutable $statusChangedAt, float $todayScore, float $tomorrowScore, float $random) : mixed
Parameters
$id : TermId
$languageId : LanguageId
$text : string
$textLowercase : string
$lemma : string|null
$lemmaLc : string|null
$status : TermStatus
$translation : string
$sentence : string
$notes : string
$romanization : string
$wordCount : int
$createdAt : DateTimeImmutable
$statusChangedAt : DateTimeImmutable
$todayScore : float
$tomorrowScore : float
$random : float

calculateWordCount()

Calculate word count for a text.

private static calculateWordCount(string $text) : int
Parameters
$text : string

The text to count words in

Return values
int

        
On this page

Search results