Documentation

CreateTerm

Use case for creating a new term/word.

Tags
since
3.0.0

Table of Contents

Properties

$repository  : TermRepositoryInterface

Methods

__construct()  : mixed
Constructor.
execute()  : Term
Execute the create term use case.
executeFromArray()  : array{id: int, message: string, success: bool, textlc: string, text: string}
Execute and return result array (backward compatible with WordService).
calculateWordCount()  : int
Calculate word count for a text.
normalizeTranslation()  : string
Normalize translation text.
replaceTabNewline()  : string
Replace tabs and newlines in text.

Properties

Methods

execute()

Execute the create term use case.

public execute(int $languageId, string $text[, int $status = 1 ][, string $translation = '' ][, string $sentence = '' ][, string $notes = '' ][, string $romanization = '' ][, int $wordCount = 0 ][, string|null $lemma = null ]) : Term
Parameters
$languageId : int

Language ID

$text : string

Term text

$status : int = 1

Learning status (1-5, 98, 99)

$translation : string = ''

Translation text

$sentence : string = ''

Example sentence

$notes : string = ''

Personal notes

$romanization : string = ''

Romanization/phonetic

$wordCount : int = 0

Word count (for multi-word expressions)

$lemma : string|null = null

Lemma (base form of the word)

Tags
throws
InvalidArgumentException

If validation fails

Return values
Term

The created term entity

executeFromArray()

Execute and return result array (backward compatible with WordService).

public executeFromArray(array<string|int, mixed> $data) : array{id: int, message: string, success: bool, textlc: string, text: string}
Parameters
$data : array<string|int, mixed>

Word data array with keys like WoLgID, WoText, etc.

Return values
array{id: int, message: string, success: bool, textlc: string, text: string}

calculateWordCount()

Calculate word count for a text.

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

The text to count words in

Return values
int

Word count (minimum 1)

normalizeTranslation()

Normalize translation text.

private normalizeTranslation(string $translation) : string
Parameters
$translation : string

Raw translation

Return values
string

Normalized translation

replaceTabNewline()

Replace tabs and newlines in text.

private replaceTabNewline(string $text) : string
Parameters
$text : string

Input text

Return values
string

Cleaned text


        
On this page

Search results