. * * @file * @ingroup Skins */ declare( strict_types=1 ); namespace MediaWiki\Skins\Citizen\Partials; use MediaWiki\MediaWikiServices; use Title; /** * Title partial of Skin Citizen */ final class PageTitle extends Partial { /** * Wrap text within parenthesis with a span tag * * @param string $data title of the page * @return string */ public function decorateTitle( $data ) { if ( $this->shouldAddParenthesis() ) { $pattern = '/(\(.+\))/'; $replacement = '$1'; return preg_replace( $pattern, $replacement, $data ); } return $data; } /** * Check if the current page is in the content namespace * * @return bool */ private function shouldAddParenthesis() : bool { $ns = $this->title->getNamespace(); $contentNs = MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(); return in_array( $ns, $contentNs ); } }