Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
85.71% covered (warning)
85.71%
6 / 7
CRAP
84.62% covered (warning)
84.62%
11 / 13
SpecialPageHtmlFragment
0.00% covered (danger)
0.00%
0 / 1
85.71% covered (warning)
85.71%
6 / 7
9.29
84.62% covered (warning)
84.62%
11 / 13
 __construct
0.00% covered (danger)
0.00%
0 / 1
3.21
71.43% covered (warning)
71.43%
5 / 7
 getPageTitle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getContext
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getOutput
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getUser
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getLanguage
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 msg
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace FileImporter\Html;
use IContextSource;
use InvalidArgumentException;
use Language;
use Message;
use MessageLocalizer;
use MutableContext;
use OutputPage;
use SpecialPage;
use Title;
use User;
/**
 * Common framework for classes providing HTML fragments (similar to
 * {@see https://developer.mozilla.org/de/docs/Web/API/Document/createDocumentFragment}) that are
 * meant to be shown on a special page. Implementations should have a `getHtml` method with as many
 * arguments as needed.
 *
 * @license GPL-2.0-or-later
 * @author Thiemo Kreuz
 */
abstract class SpecialPageHtmlFragment implements MessageLocalizer {
    /**
     * @var SpecialPage
     */
    private $specialPage;
    /**
     * Implementations should not have a constructor, but provide whatever is needed as arguments to
     * their `getHtml` method.
     *
     * @param SpecialPage|self $specialPage
     *
     * @throws InvalidArgumentException when the provided parent object is not acceptable
     */
    final public function __construct( $specialPage ) {
        if ( $specialPage instanceof self ) {
            $specialPage = $specialPage->specialPage;
        } elseif ( !( $specialPage instanceof SpecialPage ) ) {
            throw new InvalidArgumentException(
                '$specialPage must be a SpecialPage or SpecialPageHtmlFragment' );
        }
        $this->specialPage = $specialPage;
    }
    /**
     * @return Title
     */
    protected function getPageTitle() {
        return $this->specialPage->getPageTitle();
    }
    /**
     * @return IContextSource|MutableContext
     */
    protected function getContext() {
        return $this->specialPage->getContext();
    }
    /**
     * @return OutputPage
     */
    protected function getOutput() {
        return $this->specialPage->getOutput();
    }
    /**
     * @return User
     */
    protected function getUser() {
        return $this->specialPage->getUser();
    }
    /**
     * @return Language
     */
    protected function getLanguage() {
        return $this->specialPage->getLanguage();
    }
    /**
     * @see MessageLocalizer::msg
     *
     * @param string|string[]|\MessageSpecifier $key
     * @param mixed ...$params Any number of message parameters
     *
     * @return Message
     */
    public function msg( $key, ...$params ) {
        return $this->specialPage->msg( $key, ...$params );
    }
}