Documentation

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

$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

$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
string

audioPosition()

public audioPosition() : float
Return values
float

characterCount()

Get the character count of the text.

public characterCount() : int
Return values
int

create()

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

If title or content is empty

Return values
self

hasMedia()

Check if the text has media attached.

public hasMedia() : bool
Return values
bool

hasSource()

Check if the text has a source URI.

public hasSource() : bool
Return values
bool

hasStartedReading()

Check if reading has started.

public hasStartedReading() : bool
Return values
bool

isAnnotated()

Check if the text has been annotated.

public isAnnotated() : bool
Return values
bool

isLocalMedia()

Check if media is a local file.

public isLocalMedia() : bool
Return values
bool

isYouTubeMedia()

Check if media is a YouTube video.

public isYouTubeMedia() : bool
Return values
bool

mediaUri()

public mediaUri() : string
Return values
string

position()

public position() : int
Return values
int

rename()

Update the text title.

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

The new title

Tags
throws
InvalidArgumentException

If title is empty

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
string

text()

public text() : string
Return values
string

title()

public title() : string
Return values
string

updateAudioPosition()

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

If content is empty

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

        
On this page

Search results