Wikibase
MediaWiki Wikibase extension
Wikibase\DataModel\Entity\EntityId Class Reference
+ Inheritance diagram for Wikibase\DataModel\Entity\EntityId:
+ Collaboration diagram for Wikibase\DataModel\Entity\EntityId:

Public Member Functions

 __construct ( $serialization)
 
 getEntityType ()
 
 getSerialization ()
 
 getRepositoryName ()
 Returns '' for local IDs and the foreign repository name for foreign IDs. More...
 
 getLocalPart ()
 Returns the serialization without the first repository prefix. More...
 
 isForeign ()
 Returns true iff EntityId::getRepositoryName returns a non-empty string. More...
 
 __toString ()
 This is a human readable representation of the EntityId. More...
 
 equals ( $target)
 

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. More...
 
static joinSerialization (array $parts)
 Builds an ID serialization from the parts returned by EntityId::splitSerialization. More...
 

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. More...
 

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: More...
 
static normalizeIdSerialization ( $id)
 

Detailed Description

Since
0.5 Abstract since 2.0

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Entity\EntityId::__construct (   $serialization)
Since
6.2
Parameters
string$serialization
Exceptions
InvalidArgumentException

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

Member Function Documentation

◆ __toString()

Wikibase\DataModel\Entity\EntityId::__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

◆ assertValidSerialization()

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

◆ equals()

Wikibase\DataModel\Entity\EntityId::equals (   $target)
Since
0.5
Parameters
mixed$target
Returns
bool

◆ extractRepositoryNameAndLocalPart()

static Wikibase\DataModel\Entity\EntityId::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!

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

◆ extractSerializationParts()

static Wikibase\DataModel\Entity\EntityId::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()

◆ getLocalPart()

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

Returns the serialization without the first repository prefix.

Since
6.2
Returns
string

◆ getRepositoryName()

Wikibase\DataModel\Entity\EntityId::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.

Since
6.2
Returns
string

◆ getSerialization()

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

◆ isForeign()

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

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

Since
6.2
Returns
bool

◆ joinSerialization()

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

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

Since
6.2
Parameters
string[]$parts
Exceptions
InvalidArgumentException
Returns
string

◆ normalizeIdSerialization()

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

◆ splitSerialization()

static Wikibase\DataModel\Entity\EntityId::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.

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

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

Member Data Documentation

◆ $localPart

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

◆ $repositoryName

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

◆ $serialization

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

◆ PATTERN

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

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