Wikibase
MediaWiki Wikibase extension
Wikibase\DataModel\Term\TermList Class Reference

Unordered list of Term objects. More...

+ Inheritance diagram for Wikibase\DataModel\Term\TermList:
+ Collaboration diagram for Wikibase\DataModel\Term\TermList:

Public Member Functions

 __construct ($terms=[])
 
 count ()
 
 toTextArray ()
 Returns an array with language codes as keys and the term text as values. More...
 
 getIterator ()
 
 getByLanguage ( $languageCode)
 
 getWithLanguages (array $languageCodes)
 
 removeByLanguage ( $languageCode)
 
 hasTermForLanguage ( $languageCode)
 
 setTerm (Term $term)
 Replaces non-empty or removes empty terms. More...
 
 setTextForLanguage ( $languageCode, $termText)
 
 equals ( $target)
 
 isEmpty ()
 
 hasTerm (Term $term)
 
 clear ()
 Removes all terms from this list. More...
 
 addAll ($terms)
 

Private Attributes

 $terms = []
 

Detailed Description

Unordered list of Term objects.

If multiple terms with the same language code are provided, only the last one will be retained. Empty terms are skipped and treated as non-existing.

Since
0.7.3
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Term\TermList::__construct (   $terms = [])
Parameters
iterable | Term[]$termsCan be a non-array since 8.1
Exceptions
InvalidArgumentException

Member Function Documentation

◆ addAll()

Wikibase\DataModel\Term\TermList::addAll (   $terms)
Since
8.1
Parameters
iterable | Term[]$terms
Exceptions
InvalidArgumentException

◆ clear()

Wikibase\DataModel\Term\TermList::clear ( )

Removes all terms from this list.

Since
7.0

◆ count()

Wikibase\DataModel\Term\TermList::count ( )
See also
Countable::count
Returns
int

◆ equals()

Wikibase\DataModel\Term\TermList::equals (   $target)
Since
0.7.4
Parameters
mixed$target
Returns
bool

◆ getByLanguage()

Wikibase\DataModel\Term\TermList::getByLanguage (   $languageCode)
Parameters
string$languageCode
Returns
Term
Exceptions
OutOfBoundsException

◆ getIterator()

Wikibase\DataModel\Term\TermList::getIterator ( )
See also
IteratorAggregate::getIterator
Returns
Iterator|Term[]

◆ getWithLanguages()

Wikibase\DataModel\Term\TermList::getWithLanguages ( array  $languageCodes)
Since
2.5
Parameters
string[]$languageCodes
Returns
self

◆ hasTerm()

Wikibase\DataModel\Term\TermList::hasTerm ( Term  $term)
Since
0.7.4
Parameters
Term$term
Returns
boolean

◆ hasTermForLanguage()

Wikibase\DataModel\Term\TermList::hasTermForLanguage (   $languageCode)
Parameters
string$languageCode
Returns
bool

◆ isEmpty()

Wikibase\DataModel\Term\TermList::isEmpty ( )
Since
2.4.0
Returns
bool

◆ removeByLanguage()

Wikibase\DataModel\Term\TermList::removeByLanguage (   $languageCode)
Parameters
string$languageCode

◆ setTerm()

Wikibase\DataModel\Term\TermList::setTerm ( Term  $term)

Replaces non-empty or removes empty terms.

Parameters
Term$term

◆ setTextForLanguage()

Wikibase\DataModel\Term\TermList::setTextForLanguage (   $languageCode,
  $termText 
)
Since
0.8
Parameters
string$languageCode
string$termText

◆ toTextArray()

Wikibase\DataModel\Term\TermList::toTextArray ( )

Returns an array with language codes as keys and the term text as values.

Returns
string[]

Member Data Documentation

◆ $terms

Wikibase\DataModel\Term\TermList::$terms = []
private

The documentation for this class was generated from the following file: