CreateTerm
in package
Use case for creating a new term/word.
Tags
Table of Contents
Properties
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
$repository
private
TermRepositoryInterface
$repository
Methods
__construct()
Constructor.
public
__construct(TermRepositoryInterface $repository) : mixed
Parameters
- $repository : TermRepositoryInterface
-
Term repository
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
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