Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\DataModel\Entity\SerializableEntityId Class Reference
+ Inheritance diagram for Wikibase\DataModel\Entity\SerializableEntityId:
+ Collaboration diagram for Wikibase\DataModel\Entity\SerializableEntityId:

Public Member Functions

 __construct ( $serialization)
 
 getEntityType ()
 
 getSerialization ()
 
 getRepositoryName ()
 Returns '' for local IDs and the foreign repository name for foreign IDs.
 
 getLocalPart ()
 Returns the serialization without the first repository prefix.
 
 isForeign ()
 Returns true iff SerializableEntityId::getRepositoryName returns a non-empty string.
 
 __toString ()
 This is a human readable representation of the EntityId.
 
 equals ( $target)
 
 __serialize ()
 This method replaces Serializable::serialize().
 
 __unserialize (array $serialized)
 This method replaces Serializable::unserialize().
 

Static Public Member Functions

static splitSerialization ( $serialization)
 Returns an array with 3 elements: the foreign repository name as the first element, the local ID as the last element and everything that is in between as the second element.
 
static joinSerialization (array $parts)
 Builds an ID serialization from the parts returned by SerializableEntityId::splitSerialization.
 

Public Attributes

const PATTERN = '/^:?(\w+:)*[^:]+\z/'
 

Static Protected Member Functions

static extractRepositoryNameAndLocalPart ( $serialization)
 Returns a pair (repository name, local part of ID) from the given ID serialization.
 

Protected Attributes

 $serialization
 
 $repositoryName
 
 $localPart
 

Static Private Member Functions

static assertValidSerialization ( $serialization)
 
static extractSerializationParts ( $serialization)
 Splits the given ID serialization into an array with the following three elements:
 
static normalizeIdSerialization ( $id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Entity\SerializableEntityId::__construct ( $serialization)
Parameters
string$serialization
Exceptions
InvalidArgumentException

Reimplemented in Wikibase\DataModel\Entity\ItemId, and Wikibase\DataModel\Entity\NumericPropertyId.

Member Function Documentation

◆ __serialize()

Wikibase\DataModel\Entity\SerializableEntityId::__serialize ( )
abstract

◆ __toString()

Wikibase\DataModel\Entity\SerializableEntityId::__toString ( )

This is a human readable representation of the EntityId.

This format is allowed to change and should therefore not be relied upon to be stable.

Returns
string

Implements Wikibase\DataModel\Entity\EntityId.

◆ __unserialize()

Wikibase\DataModel\Entity\SerializableEntityId::__unserialize ( array $data)
abstract

◆ assertValidSerialization()

static Wikibase\DataModel\Entity\SerializableEntityId::assertValidSerialization ( $serialization)
staticprivate

◆ equals()

Wikibase\DataModel\Entity\SerializableEntityId::equals ( $target)
Parameters
mixed$target
Returns
bool

Implements Wikibase\DataModel\Entity\EntityId.

◆ extractRepositoryNameAndLocalPart()

static Wikibase\DataModel\Entity\SerializableEntityId::extractRepositoryNameAndLocalPart ( $serialization)
staticprotected

Returns a pair (repository name, local part of ID) from the given ID serialization.

Note: this does not perform any validation of the given input. Calling code should take care of this!

Parameters
string$serialization
Returns
string[] Array of form [ string $repositoryName, string $localPart ]

◆ extractSerializationParts()

static Wikibase\DataModel\Entity\SerializableEntityId::extractSerializationParts ( $serialization)
staticprivate

Splits the given ID serialization into an array with the following three elements:

  • the repository name as the first element (empty string for local repository)
  • any parts of the ID serialization but the repository name and the local ID (if any, empty string if nothing else present)
  • the local ID Note: this method does not perform any validation of the given input. Calling code should take care of this!
Parameters
string$serialization
Returns
string[]

◆ getEntityType()

Wikibase\DataModel\Entity\SerializableEntityId::getEntityType ( )
abstract

◆ getLocalPart()

Wikibase\DataModel\Entity\SerializableEntityId::getLocalPart ( )

Returns the serialization without the first repository prefix.

Returns
string

Implements Wikibase\DataModel\Entity\EntityId.

◆ getRepositoryName()

Wikibase\DataModel\Entity\SerializableEntityId::getRepositoryName ( )

Returns '' for local IDs and the foreign repository name for foreign IDs.

For chained IDs (e.g. foo:bar:Q42) it will return only the first part.

Returns
string

Implements Wikibase\DataModel\Entity\EntityId.

◆ getSerialization()

Wikibase\DataModel\Entity\SerializableEntityId::getSerialization ( )
Returns
string

Implements Wikibase\DataModel\Entity\EntityId.

◆ isForeign()

Wikibase\DataModel\Entity\SerializableEntityId::isForeign ( )

Returns true iff SerializableEntityId::getRepositoryName returns a non-empty string.

Returns
bool

◆ joinSerialization()

static Wikibase\DataModel\Entity\SerializableEntityId::joinSerialization ( array $parts)
static

Builds an ID serialization from the parts returned by SerializableEntityId::splitSerialization.

Parameters
string[]$parts
Exceptions
InvalidArgumentException
Returns
string

◆ normalizeIdSerialization()

static Wikibase\DataModel\Entity\SerializableEntityId::normalizeIdSerialization ( $id)
staticprivate
Parameters
string$id
Returns
string

◆ splitSerialization()

static Wikibase\DataModel\Entity\SerializableEntityId::splitSerialization ( $serialization)
static

Returns an array with 3 elements: the foreign repository name as the first element, the local ID as the last element and everything that is in between as the second element.

SerializableEntityId::joinSerialization can be used to restore the original serialization from the parts returned.

Parameters
string$serialization
Exceptions
InvalidArgumentException
Returns
string[] Array containing the serialization split into 3 parts.

Member Data Documentation

◆ $localPart

Wikibase\DataModel\Entity\SerializableEntityId::$localPart
protected

◆ $repositoryName

Wikibase\DataModel\Entity\SerializableEntityId::$repositoryName
protected

◆ $serialization

Wikibase\DataModel\Entity\SerializableEntityId::$serialization
protected

◆ PATTERN

const Wikibase\DataModel\Entity\SerializableEntityId::PATTERN = '/^:?(\w+:)*[^:]+\z/'

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