Tag
in package
Tag entity representing a term tag or text tag.
Tags are used to categorize words (term tags) or texts (text tags). Both types share the same structure: ID, text, and comment.
Tags
Table of Contents
Constants
- MAX_COMMENT_LENGTH = 200
- Maximum length for tag comment.
- MAX_TEXT_LENGTH = 20
- Maximum length for tag text.
Properties
Methods
- comment() : string
- Get the tag comment.
- create() : self
- Create a new tag.
- id() : TagId
- Get the tag ID.
- isNew() : bool
- Check if this is an unsaved entity.
- isTermTag() : bool
- Check if this is a term tag.
- isTextTag() : bool
- Check if this is a text tag.
- rename() : void
- Rename the tag.
- text() : string
- Get the tag text.
- toArray() : array{id: int, text: string, comment: string, type: string}
- Convert to array for backward compatibility.
- type() : TagType
- Get the tag type.
- updateComment() : void
- Update the tag comment.
- __construct() : mixed
- Private constructor - use factory methods instead.
- normalizeText() : string
- Normalize tag text.
- validateComment() : void
- Validate tag comment.
- validateText() : void
- Validate tag text.
Constants
MAX_COMMENT_LENGTH
Maximum length for tag comment.
public
mixed
MAX_COMMENT_LENGTH
= 200
MAX_TEXT_LENGTH
Maximum length for tag text.
public
mixed
MAX_TEXT_LENGTH
= 20
Properties
$comment
private
string
$comment
$id
private
TagId
$id
$text
private
string
$text
$type
private
TagType
$type
Methods
comment()
Get the tag comment.
public
comment() : string
Return values
stringcreate()
Create a new tag.
public
static create(TagType $type, string $text[, string $comment = '' ]) : self
Parameters
- $type : TagType
-
Tag type (term or text)
- $text : string
-
Tag text (max 20 chars, no spaces/commas)
- $comment : string = ''
-
Tag comment (max 200 chars)
Tags
Return values
selfid()
Get the tag ID.
public
id() : TagId
Return values
TagIdisNew()
Check if this is an unsaved entity.
public
isNew() : bool
Return values
boolisTermTag()
Check if this is a term tag.
public
isTermTag() : bool
Return values
boolisTextTag()
Check if this is a text tag.
public
isTextTag() : bool
Return values
boolrename()
Rename the tag.
public
rename(string $text) : void
Parameters
- $text : string
-
New tag text
Tags
text()
Get the tag text.
public
text() : string
Return values
stringtoArray()
Convert to array for backward compatibility.
public
toArray() : array{id: int, text: string, comment: string, type: string}
Return values
array{id: int, text: string, comment: string, type: string}type()
Get the tag type.
public
type() : TagType
Return values
TagTypeupdateComment()
Update the tag comment.
public
updateComment(string $comment) : void
Parameters
- $comment : string
-
New comment
Tags
__construct()
Private constructor - use factory methods instead.
private
__construct(TagId $id, TagType $type, string $text, string $comment) : mixed
Parameters
normalizeText()
Normalize tag text.
private
static normalizeText(string $text) : string
Trims whitespace and removes spaces/commas (not allowed in tags).
Parameters
- $text : string
-
Raw tag text
Return values
string —Normalized text
validateComment()
Validate tag comment.
private
static validateComment(string $comment) : void
Parameters
- $comment : string
-
The comment to validate
Tags
validateText()
Validate tag text.
private
static validateText(string $text) : void
Parameters
- $text : string
-
The text to validate