Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
37.50% covered (danger)
37.50%
3 / 8
25.00% covered (danger)
25.00%
1 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
NullReplacementMachine
37.50% covered (danger)
37.50%
3 / 8
25.00% covered (danger)
25.00%
1 / 4
11.10
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getCodes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isValidCodePair
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 convert
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\LangConv;
4
5/**
6 * A replacement machine that leaves text untouched.
7 */
8class NullReplacementMachine extends ReplacementMachine {
9    private $baseLanguage;
10    private $codes = [];
11
12    /**
13     * Create a NullReplacementMachine.
14     * @param string $baseLanguage A base language code
15     */
16    public function __construct( string $baseLanguage ) {
17        $this->baseLanguage = $baseLanguage;
18        $this->codes[$baseLanguage] = $baseLanguage;
19    }
20
21    /**
22     * @inheritDoc
23     */
24    public function getCodes() {
25        return $this->codes;
26    }
27
28    /**
29     * @inheritDoc
30     */
31    public function isValidCodePair( $destCode, $invertCode ) {
32        return $destCode === $this->baseLanguage &&
33            $invertCode === $this->baseLanguage;
34    }
35
36    /**
37     * @inheritDoc
38     */
39    public function convert( $document, $s, $destCode, $invertCode ) {
40        $result = $document->createDocumentFragment();
41        $result->appendChild( $document->createTextNode( $s ) );
42        return $result;
43    }
44}