Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\DataModel\Snak\SnakList Class Reference

List of Snak objects. More...

+ Inheritance diagram for Wikibase\DataModel\Snak\SnakList:
+ Collaboration diagram for Wikibase\DataModel\Snak\SnakList:

Public Member Functions

 __construct ( $snaks=[])
 
 hasSnakHash ( $snakHash)
 
 removeSnakHash ( $snakHash)
 
 addSnak (Snak $snak)
 
 hasSnak (Snak $snak)
 
 removeSnak (Snak $snak)
 
 getSnak ( $snakHash)
 
 equals ( $target)
 The comparison is done purely value based, ignoring the order of the elements in the array.
 
 getHash ()
 The hash is purely value based.
 
 append ( $value)
 
 offsetSet ( $index, $value)
 
 serialize ()
 
 unserialize ( $serialized)
 
 __serialize ()
 
 __unserialize ( $data)
 
 isEmpty ()
 Returns if the ArrayObject has no elements.
 

Private Member Functions

 getNewOffset ()
 Finds a new offset for when appending an element.
 
 setElement ( $index, $value)
 Method that actually sets the element and holds all common code needed for set operations, including type checking and offset resolving.
 

Private Attributes

 $offsetHashes = []
 
 $indexOffset = 0
 

Detailed Description

List of Snak objects.

Indexes the snaks by hash and ensures no more the one snak with the same hash are in the list.

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

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Snak\SnakList::__construct ( $snaks = [])
Parameters
Snak[] | Traversable$snaks
Exceptions
InvalidArgumentException

Member Function Documentation

◆ __serialize()

Wikibase\DataModel\Snak\SnakList::__serialize ( )

◆ __unserialize()

Wikibase\DataModel\Snak\SnakList::__unserialize ( $data)

◆ addSnak()

Wikibase\DataModel\Snak\SnakList::addSnak ( Snak $snak)
Since
0.1
Parameters
Snak$snak
Returns
bool Indicates if the snak was added or not.

◆ append()

Wikibase\DataModel\Snak\SnakList::append ( $value)
See also
ArrayObject::append
Parameters
Snak$value

◆ equals()

Wikibase\DataModel\Snak\SnakList::equals ( $target)

The comparison is done purely value based, ignoring the order of the elements in the array.

Since
0.3
Parameters
mixed$target
Returns
bool

◆ getHash()

Wikibase\DataModel\Snak\SnakList::getHash ( )

The hash is purely value based.

Order of the elements in the array is not held into account.

Since
0.1
Returns
string

◆ getNewOffset()

Wikibase\DataModel\Snak\SnakList::getNewOffset ( )
private

Finds a new offset for when appending an element.

The base class does this, so it would be better to integrate, but there does not appear to be any way to do this...

Returns
int

◆ getSnak()

Wikibase\DataModel\Snak\SnakList::getSnak ( $snakHash)
Since
0.1
Parameters
string$snakHash
Returns
Snak|bool

◆ hasSnak()

Wikibase\DataModel\Snak\SnakList::hasSnak ( Snak $snak)
Since
0.1
Parameters
Snak$snak
Returns
bool

◆ hasSnakHash()

Wikibase\DataModel\Snak\SnakList::hasSnakHash ( $snakHash)
Since
0.1
Parameters
string$snakHash
Returns
bool

◆ isEmpty()

Wikibase\DataModel\Snak\SnakList::isEmpty ( )

Returns if the ArrayObject has no elements.

Returns
bool

◆ offsetSet()

Wikibase\DataModel\Snak\SnakList::offsetSet ( $index,
$value )
See also
ArrayObject::offsetSet()
Parameters
int | string$index
Snak$value

◆ removeSnak()

Wikibase\DataModel\Snak\SnakList::removeSnak ( Snak $snak)
Since
0.1
Parameters
Snak$snak

◆ removeSnakHash()

Wikibase\DataModel\Snak\SnakList::removeSnakHash ( $snakHash)
Since
0.1
Parameters
string$snakHash

◆ serialize()

Wikibase\DataModel\Snak\SnakList::serialize ( )
See also
Serializable::serialize
Returns
string

◆ setElement()

Wikibase\DataModel\Snak\SnakList::setElement ( $index,
$value )
private

Method that actually sets the element and holds all common code needed for set operations, including type checking and offset resolving.

Parameters
int | string$index
Snak$value
Exceptions
InvalidArgumentException

◆ unserialize()

Wikibase\DataModel\Snak\SnakList::unserialize ( $serialized)
See also
Serializable::unserialize
Parameters
string$serialized

Member Data Documentation

◆ $indexOffset

Wikibase\DataModel\Snak\SnakList::$indexOffset = 0
private

◆ $offsetHashes

Wikibase\DataModel\Snak\SnakList::$offsetHashes = []
private

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