Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
25.00% covered (danger)
25.00%
1 / 4
CRAP
33.33% covered (danger)
33.33%
3 / 9
NullReplacementMachine
0.00% covered (danger)
0.00%
0 / 1
25.00% covered (danger)
25.00%
1 / 4
12.41
33.33% covered (danger)
33.33%
3 / 9
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getCodes
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 isValidCodePair
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 convert
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
<?php
namespace Wikimedia\LangConv;
/**
 * A replacement machine that leaves text untouched.
 */
class NullReplacementMachine extends ReplacementMachine {
    private $baseLanguage;
    private $codes = [];
    /**
     * Create a NullReplacementMachine.
     * @param string $baseLanguage A base language code
     */
    public function __construct( string $baseLanguage ) {
        $this->baseLanguage = $baseLanguage;
        $this->codes[$baseLanguage] = $baseLanguage;
    }
    /**
     * @inheritDoc
     */
    public function getCodes() {
        return $this->codes;
    }
    /**
     * @inheritDoc
     */
    public function isValidCodePair( $destCode, $invertCode ) {
        return $destCode === $this->baseLanguage &&
            $invertCode === $this->baseLanguage;
    }
    /**
     * @inheritDoc
     */
    public function convert( $document, $s, $destCode, $invertCode ) {
        $result = $document->createDocumentFragment();
        $result->appendChild( $document->createTextNode( $s ) );
        return $result;
    }
}