Text
in package
A text represented as a rich domain object.
Texts are the primary learning material. Users read texts and learn vocabulary from them. Each text belongs to a language and can have associated media (audio/video).
Tags
Table of Contents
Properties
- $annotatedText : string
- $audioPosition : float
- $id : TextId
- $languageId : LanguageId
- $mediaUri : string
- $position : int
- $sourceUri : string
- $text : string
- $title : string
Methods
- annotatedText() : string
- audioPosition() : float
- characterCount() : int
- Get the character count of the text.
- create() : self
- Create a new text.
- hasMedia() : bool
- Check if the text has media attached.
- hasSource() : bool
- Check if the text has a source URI.
- hasStartedReading() : bool
- Check if reading has started.
- id() : TextId
- isAnnotated() : bool
- Check if the text has been annotated.
- isLocalMedia() : bool
- Check if media is a local file.
- isYouTubeMedia() : bool
- Check if media is a YouTube video.
- languageId() : LanguageId
- mediaUri() : string
- position() : int
- rename() : void
- Update the text title.
- resetProgress() : void
- Reset reading progress.
- setAnnotatedText() : void
- Set the annotated version of the text.
- setMediaUri() : void
- Set the media URI (audio or video).
- setSourceUri() : void
- Set the source URI.
- sourceUri() : string
- text() : string
- title() : string
- updateAudioPosition() : void
- Update the audio position.
- updateContent() : void
- Update the text content.
- updatePosition() : void
- Update the reading position.
- wordCount() : int
- Get the word count of the text.
- __construct() : mixed
- Private constructor - use factory methods instead.
Properties
$annotatedText
private
string
$annotatedText
$audioPosition
private
float
$audioPosition
$id
private
TextId
$id
$languageId
private
LanguageId
$languageId
$mediaUri
private
string
$mediaUri
$position
private
int
$position
$sourceUri
private
string
$sourceUri
$text
private
string
$text
$title
private
string
$title
Methods
annotatedText()
public
annotatedText() : string
Return values
stringaudioPosition()
public
audioPosition() : float
Return values
floatcharacterCount()
Get the character count of the text.
public
characterCount() : int
Return values
intcreate()
Create a new text.
public
static create(LanguageId $languageId, string $title, string $content) : self
Parameters
- $languageId : LanguageId
-
The language this text is in
- $title : string
-
Text title
- $content : string
-
The actual text content
Tags
Return values
selfhasMedia()
Check if the text has media attached.
public
hasMedia() : bool
Return values
boolhasSource()
Check if the text has a source URI.
public
hasSource() : bool
Return values
boolhasStartedReading()
Check if reading has started.
public
hasStartedReading() : bool
Return values
boolid()
public
id() : TextId
Return values
TextIdisAnnotated()
Check if the text has been annotated.
public
isAnnotated() : bool
Return values
boolisLocalMedia()
Check if media is a local file.
public
isLocalMedia() : bool
Return values
boolisYouTubeMedia()
Check if media is a YouTube video.
public
isYouTubeMedia() : bool
Return values
boollanguageId()
public
languageId() : LanguageId
Return values
LanguageIdmediaUri()
public
mediaUri() : string
Return values
stringposition()
public
position() : int
Return values
intrename()
Update the text title.
public
rename(string $title) : void
Parameters
- $title : string
-
The new title
Tags
resetProgress()
Reset reading progress.
public
resetProgress() : void
setAnnotatedText()
Set the annotated version of the text.
public
setAnnotatedText(string $annotated) : void
Parameters
- $annotated : string
-
The annotated text
setMediaUri()
Set the media URI (audio or video).
public
setMediaUri(string $uri) : void
Parameters
- $uri : string
-
The media URI (URL or local path)
setSourceUri()
Set the source URI.
public
setSourceUri(string $uri) : void
Parameters
- $uri : string
-
The source URI
sourceUri()
public
sourceUri() : string
Return values
stringtext()
public
text() : string
Return values
stringtitle()
public
title() : string
Return values
stringupdateAudioPosition()
Update the audio position.
public
updateAudioPosition(float $position) : void
Parameters
- $position : float
-
The new audio position in seconds
updateContent()
Update the text content.
public
updateContent(string $content) : void
Note: This will invalidate any existing annotations.
Parameters
- $content : string
-
The new content
Tags
updatePosition()
Update the reading position.
public
updatePosition(int $position) : void
Parameters
- $position : int
-
The new position
wordCount()
Get the word count of the text.
public
wordCount() : int
Return values
int__construct()
Private constructor - use factory methods instead.
private
__construct(TextId $id, LanguageId $languageId, string $title, string $text, string $annotatedText, string $mediaUri, string $sourceUri, int $position, float $audioPosition) : mixed
Parameters
- $id : TextId
- $languageId : LanguageId
- $title : string
- $text : string
- $annotatedText : string
- $mediaUri : string
- $sourceUri : string
- $position : int
- $audioPosition : float