Term
in package
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
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
$id
private
TermId
$id
$languageId
private
LanguageId
$languageId
$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
$status
private
TermStatus
$status
$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
Return values
selfcreatedAt()
public
createdAt() : DateTimeImmutable
Return values
DateTimeImmutabledecreaseStatus()
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
boolid()
public
id() : TermId
Return values
TermIdignore()
Mark the term as ignored.
public
ignore() : void
isIgnored()
Check if the term is ignored.
public
isIgnored() : bool
Return values
boolisKnown()
Check if the term is known (learned or well-known).
public
isKnown() : bool
Return values
boolisLearning()
Check if the term is in a learning stage.
public
isLearning() : bool
Return values
boolisMultiWord()
Check if this is a multi-word term.
public
isMultiWord() : bool
Return values
boollanguageId()
public
languageId() : LanguageId
Return values
LanguageIdlemma()
public
lemma() : string|null
Return values
string|nulllemmaLc()
public
lemmaLc() : string|null
Return values
string|nullmarkAsLearned()
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
boolnotes()
public
notes() : string
Return values
stringrandom()
public
random() : float
Return values
floatromanization()
public
romanization() : string
Return values
stringsentence()
public
sentence() : string
Return values
stringsetStatus()
Set the term's status to a specific value.
public
setStatus(TermStatus $status) : void
Parameters
- $status : TermStatus
-
The new status
status()
public
status() : TermStatus
Return values
TermStatusstatusChangedAt()
public
statusChangedAt() : DateTimeImmutable
Return values
DateTimeImmutabletext()
public
text() : string
Return values
stringtextLowercase()
public
textLowercase() : string
Return values
stringtodayScore()
public
todayScore() : float
Return values
floattomorrowScore()
public
tomorrowScore() : float
Return values
floattranslation()
public
translation() : string
Return values
stringupdateLemma()
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