Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
LanguageInconsistent
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 2
6
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
 asApiMessage
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Wikibase\Lexeme\MediaWiki\Api\Error;
4
5use MediaWiki\Api\ApiMessage;
6use MediaWiki\Message\Message;
7
8/**
9 * @license GPL-2.0-or-later
10 */
11class LanguageInconsistent implements ApiError {
12
13    /**
14     * @var string
15     */
16    private $expectedLanguage;
17
18    /**
19     * @var string
20     */
21    private $givenLanguage;
22
23    /**
24     * @param string $expectedLanguage
25     * @param string $givenLanguage
26     */
27    public function __construct( $expectedLanguage, $givenLanguage ) {
28        $this->expectedLanguage = $expectedLanguage;
29        $this->givenLanguage = $givenLanguage;
30    }
31
32    /** @inheritDoc */
33    public function asApiMessage( $parameterName, array $path ) {
34        $message = new Message(
35            'apierror-wikibaselexeme-language-inconsistent',
36            [ $parameterName, implode( '/', $path ), $this->expectedLanguage, $this->givenLanguage ]
37        );
38        return new ApiMessage(
39            $message,
40            'inconsistent-language',
41            [
42                'parameterName' => $parameterName,
43                'fieldPath' => $path,
44            ]
45        );
46    }
47
48}