*
* @var array[]
*/
- protected $localIds = array();
+ protected $localIds = [];
/**
* @since 1.21
*
* @var array
*/
- protected $extraData = array();
+ protected $extraData = [];
/**
* @since 1.21
*
* @var array
*/
- protected $extraConfig = array();
+ protected $extraConfig = [];
/**
* @since 1.21
protected $internalId = null;
/**
- * Constructor.
- *
* @since 1.21
*
* @param string $type
* @param string $languageCode
*/
public function setLanguageCode( $languageCode ) {
+ if ( !Language::isValidCode( $languageCode ) ) {
+ throw new InvalidArgumentException( "$languageCode is not a valid language code." );
+ }
$this->languageCode = $languageCode;
}
*/
public function addLocalId( $type, $identifier ) {
if ( $this->localIds === false ) {
- $this->localIds = array();
+ $this->localIds = [];
}
if ( !array_key_exists( $type, $this->localIds ) ) {
- $this->localIds[$type] = array();
+ $this->localIds[$type] = [];
}
if ( !in_array( $identifier, $this->localIds[$type] ) ) {
public function getInterwikiIds() {
return array_key_exists( self::ID_INTERWIKI, $this->localIds )
? $this->localIds[self::ID_INTERWIKI]
- : array();
+ : [];
}
/**
public function getNavigationIds() {
return array_key_exists( self::ID_EQUIVALENT, $this->localIds )
? $this->localIds[self::ID_EQUIVALENT] :
- array();
+ [];
}
/**
}
if ( !array_key_exists( 'paths', $this->extraData ) ) {
- $this->extraData['paths'] = array();
+ $this->extraData['paths'] = [];
}
$this->extraData['paths'][$pathType] = $fullUrl;
* @return string[]
*/
public function getAllPaths() {
- return array_key_exists( 'paths', $this->extraData ) ? $this->extraData['paths'] : array();
+ return array_key_exists( 'paths', $this->extraData ) ? $this->extraData['paths'] : [];
}
/**
* @return string
*/
public function serialize() {
- $fields = array(
+ $fields = [
'globalid' => $this->globalId,
'type' => $this->type,
'group' => $this->group,
'forward' => $this->forward,
'internalid' => $this->internalId,
- );
+ ];
return serialize( $fields );
}