Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
JsonFieldIsRequired
83.33% covered (warning)
83.33%
5 / 6
50.00% covered (danger)
50.00%
1 / 2
2.02
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 asApiMessage
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
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 JsonFieldIsRequired implements ApiError {
12
13    /**
14     * @var string
15     */
16    private $field;
17
18    /**
19     * @param string $field
20     */
21    public function __construct( $field ) {
22        $this->field = $field;
23    }
24
25    /**
26     * @inheritDoc
27     */
28    public function asApiMessage( $parameterName, array $path ) {
29        $message = new Message(
30            'apierror-wikibaselexeme-json-field-required',
31            [ $parameterName, implode( '/', $path ), $this->field ]
32        );
33        return new ApiMessage( $message, 'bad-request' );
34    }
35
36}