Documentation

TermStatus

Read onlyYes
FinalYes

Value object representing a Term's learning status.

Encapsulates the business rules around term status transitions.

Status values:

  • 1-5: Learning stages (1=new, 5=learned)
  • 98: Ignored words
  • 99: Well-known words
Tags
since
3.0.0

Table of Contents

Constants

IGNORED  = 98
LEARNED  = 5
LEARNING_2  = 2
LEARNING_3  = 3
LEARNING_4  = 4
NEW  = 1
WELL_KNOWN  = 99
ABBREVIATIONS  = [self::NEW => '1', self::LEARNING_2 => '2', self::LEARNING_3 => '3', self::LEARNING_4 => '4', self::LEARNED => '5', self::WELL_KNOWN => '', self::IGNORED => '']
Language-neutral abbreviations.
COLOURS  = [self::NEW => '#E85A3C', self::LEARNING_2 => '#E8893C', self::LEARNING_3 => '#E8B83C', self::LEARNING_4 => '#E8E23C', self::LEARNED => '#66CC66', self::WELL_KNOWN => '#CCFFCC', self::IGNORED => '#888888']
Canonical light-theme colour for each status.
CSS_CLASSES  = [self::NEW => 'status1', self::LEARNING_2 => 'status2', self::LEARNING_3 => 'status3', self::LEARNING_4 => 'status4', self::LEARNED => 'status5', self::WELL_KNOWN => 'status99', self::IGNORED => 'status98']
CSS class names used by the reading view and status charts.
VALID_STATUSES  = [self::NEW, self::LEARNING_2, self::LEARNING_3, self::LEARNING_4, self::LEARNED, self::WELL_KNOWN, self::IGNORED]

Properties

$value  : int

Methods

__toString()  : string
String representation.
abbreviation()  : string
Language-neutral abbreviation ('1'..'5'); empty for 98/99, where display code should fall back to {@see displayName()}.
advance()  : self
Advance to the next learning stage.
colourHex()  : string
Canonical light-theme colour hex (e.g. '#E85A3C'). Mirrors the `--lwt-status*` CSS variables for machine clients.
cssClass()  : string
CSS class used by the reading view and status charts (e.g. 'status1').
decrease()  : self
Decrease to the previous learning stage.
definitions()  : array<int, array{value: int, name: string, abbr: string, cssClass: string, colour: string, order: int, isKnown: bool, isLearning: bool, isIgnored: bool}>
Full machine-readable definition of every status, in display order.
displayName()  : string
Localized, user-facing status name.
equals()  : bool
Check equality with another TermStatus.
fromInt()  : self
Create from a database value.
ignored()  : self
Create an ignored status.
isIgnored()  : bool
Check if the term is ignored.
isIgnoredValue()  : bool
Whether a raw status value represents an ignored term.
isKnown()  : bool
Check if the term is known (learned or well-known).
isKnownValue()  : bool
Whether a raw status value represents a known term (learned or well-known). Returns false for invalid values rather than throwing, so it is safe to call on unvalidated input.
isLearning()  : bool
Check if the term is in a learning stage (1-4).
isLearningValue()  : bool
Whether a raw status value is a learning stage (1-5).
isSpecial()  : bool
Check if this is a special status (ignored or well-known).
isValid()  : bool
Check whether an integer is a valid term status.
label()  : string
Get a human-readable label.
learned()  : self
Create a learned status.
needsReview()  : bool
Check if the term needs review (learning stages 1-4).
new()  : self
Create a new (unknown) status.
order()  : int
Position in the canonical display order (1-based).
toInt()  : int
Get the integer value.
values()  : array<string|int, int>
All valid status values, in canonical display order (learning 1-5, then well-known, then ignored).
wellKnown()  : self
Create a well-known status.
__construct()  : mixed
translate()  : string
Resolve a translation key, falling back to a sensible English label when the translator is unavailable (e.g. during a Container reset).

Constants

LEARNING_2

public int LEARNING_2 = 2

Learning stage 2

LEARNING_3

public int LEARNING_3 = 3

Learning stage 3

LEARNING_4

public int LEARNING_4 = 4

Learning stage 4

WELL_KNOWN

public int WELL_KNOWN = 99

Well-known term (no need to learn)

ABBREVIATIONS

Language-neutral abbreviations.

private array<int, string> ABBREVIATIONS = [self::NEW => '1', self::LEARNING_2 => '2', self::LEARNING_3 => '3', self::LEARNING_4 => '4', self::LEARNED => '5', self::WELL_KNOWN => '', self::IGNORED => '']

Learning levels use their digit; 98/99 have no good cross-language abbreviation, so the empty string signals "fall back to the full name".

COLOURS

Canonical light-theme colour for each status.

private array<int, string> COLOURS = [self::NEW => '#E85A3C', self::LEARNING_2 => '#E8893C', self::LEARNING_3 => '#E8B83C', self::LEARNING_4 => '#E8E23C', self::LEARNED => '#66CC66', self::WELL_KNOWN => '#CCFFCC', self::IGNORED => '#888888']

These mirror the --lwt-status* CSS custom properties (the visual source of truth for the web UI); they are exposed here so machine clients (the mobile app, the REST API) have concrete values.

CSS_CLASSES

CSS class names used by the reading view and status charts.

private array<int, string> CSS_CLASSES = [self::NEW => 'status1', self::LEARNING_2 => 'status2', self::LEARNING_3 => 'status3', self::LEARNING_4 => 'status4', self::LEARNED => 'status5', self::WELL_KNOWN => 'status99', self::IGNORED => 'status98']

VALID_STATUSES

private array<string|int, int> VALID_STATUSES = [self::NEW, self::LEARNING_2, self::LEARNING_3, self::LEARNING_4, self::LEARNED, self::WELL_KNOWN, self::IGNORED]

Valid status values, in canonical display order

Properties

Methods

__toString()

String representation.

public __toString() : string
Return values
string

abbreviation()

Language-neutral abbreviation ('1'..'5'); empty for 98/99, where display code should fall back to {@see displayName()}.

public abbreviation() : string
Return values
string

advance()

Advance to the next learning stage.

public advance() : self

Returns a new TermStatus with the next stage, or the same status if already at maximum learning level or special status.

Return values
self

colourHex()

Canonical light-theme colour hex (e.g. '#E85A3C'). Mirrors the `--lwt-status*` CSS variables for machine clients.

public colourHex() : string
Return values
string

cssClass()

CSS class used by the reading view and status charts (e.g. 'status1').

public cssClass() : string
Return values
string

decrease()

Decrease to the previous learning stage.

public decrease() : self

Returns a new TermStatus with the previous stage, or the same status if already at minimum level or special status.

Return values
self

definitions()

Full machine-readable definition of every status, in display order.

public static definitions() : array<int, array{value: int, name: string, abbr: string, cssClass: string, colour: string, order: int, isKnown: bool, isLearning: bool, isIgnored: bool}>

This is the single source of truth shared by the PHP UI, the REST API (GET /api/v1/settings/status-definitions) and — via that endpoint — the frontend status store.

Return values
array<int, array{value: int, name: string, abbr: string, cssClass: string, colour: string, order: int, isKnown: bool, isLearning: bool, isIgnored: bool}>

displayName()

Localized, user-facing status name.

public displayName() : string

Learning stages 1-4 all read "Learning"; 5 is "Learned". Unlike label() (a fixed English developer label), this is translated and is what the UI and API surface to users.

Return values
string

equals()

Check equality with another TermStatus.

public equals(TermStatus $other) : bool
Parameters
$other : TermStatus

The other status to compare

Return values
bool

fromInt()

Create from a database value.

public static fromInt(int $status) : self
Parameters
$status : int

The status value from database

Tags
throws
InvalidArgumentException

If status is invalid

Return values
self

ignored()

Create an ignored status.

public static ignored() : self
Return values
self

isIgnored()

Check if the term is ignored.

public isIgnored() : bool
Return values
bool

isIgnoredValue()

Whether a raw status value represents an ignored term.

public static isIgnoredValue(int $status) : bool
Parameters
$status : int

The status value

Return values
bool

isKnown()

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

public isKnown() : bool
Return values
bool

isKnownValue()

Whether a raw status value represents a known term (learned or well-known). Returns false for invalid values rather than throwing, so it is safe to call on unvalidated input.

public static isKnownValue(int $status) : bool
Parameters
$status : int

The status value

Return values
bool

isLearning()

Check if the term is in a learning stage (1-4).

public isLearning() : bool
Return values
bool

isLearningValue()

Whether a raw status value is a learning stage (1-5).

public static isLearningValue(int $status) : bool
Parameters
$status : int

The status value

Return values
bool

isSpecial()

Check if this is a special status (ignored or well-known).

public isSpecial() : bool
Return values
bool

isValid()

Check whether an integer is a valid term status.

public static isValid(int $status) : bool
Parameters
$status : int

The status value to check

Return values
bool

label()

Get a human-readable label.

public label() : string
Return values
string

learned()

Create a learned status.

public static learned() : self
Return values
self

needsReview()

Check if the term needs review (learning stages 1-4).

public needsReview() : bool
Return values
bool

new()

Create a new (unknown) status.

public static new() : self
Return values
self

order()

Position in the canonical display order (1-based).

public order() : int
Return values
int

toInt()

Get the integer value.

public toInt() : int
Return values
int

values()

All valid status values, in canonical display order (learning 1-5, then well-known, then ignored).

public static values() : array<string|int, int>
Return values
array<string|int, int>

wellKnown()

Create a well-known status.

public static wellKnown() : self
Return values
self

__construct()

private __construct(int $value) : mixed
Parameters
$value : int

The status value

translate()

Resolve a translation key, falling back to a sensible English label when the translator is unavailable (e.g. during a Container reset).

private static translate(string $key) : string
Parameters
$key : string
Return values
string

        
On this page

Search results