Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
LexemeNotFoundException
90.91% covered (success)
90.91%
10 / 11
66.67% covered (warning)
66.67%
2 / 3
4.01
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
 getErrorMessage
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getApiErrorCode
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Wikibase\Lexeme\Domain\Merge\Exceptions;
4
5use MediaWiki\Message\Message;
6use Throwable;
7use Wikibase\Lexeme\Domain\Model\LexemeId;
8
9/**
10 * @license GPL-2.0-or-later
11 */
12class LexemeNotFoundException extends MergingException {
13
14    /**
15     * @var LexemeId
16     */
17    private $lexemeId;
18
19    public function __construct(
20        LexemeId $lexemeId,
21        ?string $message = null,
22        ?Throwable $previous = null
23    ) {
24        parent::__construct(
25            $message ?: "Lexeme {$lexemeId->getSerialization()} not found",
26            0,
27            $previous
28        );
29
30        $this->lexemeId = $lexemeId;
31    }
32
33    public function getErrorMessage(): Message {
34        return new Message(
35            'wikibase-lexeme-mergelexemes-error-lexeme-not-found',
36            [ $this->lexemeId->getSerialization() ]
37        );
38    }
39
40    public function getApiErrorCode() {
41        return 'no-such-entity';
42    }
43
44}