Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
8 / 9
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
LexemeNotFound
88.89% covered (warning)
88.89%
8 / 9
50.00% covered (danger)
50.00%
1 / 2
2.01
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%
8 / 8
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;
7use Wikibase\Lexeme\Domain\Model\LexemeId;
8
9/**
10 * @license GPL-2.0-or-later
11 */
12class LexemeNotFound implements ApiError {
13
14    /**
15     * @var LexemeId
16     */
17    private $lexemeId;
18
19    public function __construct( LexemeId $lexemeId ) {
20        $this->lexemeId = $lexemeId;
21    }
22
23    /**
24     * @return ApiMessage
25     */
26    public function asApiMessage( $parameterName, array $path ) {
27        $message = new Message(
28            'apierror-wikibaselexeme-lexeme-not-found',
29            [ $parameterName, $this->lexemeId->getSerialization() ]
30        );
31        return new ApiMessage( $message, 'not-found', [
32            'parameterName' => $parameterName,
33            'fieldPath' => [],
34        ] );
35    }
36
37}