Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| EntityRevisionLookupLexemeRevisionMetadataRetriever | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLatestRevisionMetadata | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare( strict_types=1 ); |
| 2 | |
| 3 | namespace Wikibase\Lexeme\DataAccess\Store; |
| 4 | |
| 5 | use Wikibase\Lexeme\Domain\Model\LexemeId; |
| 6 | use Wikibase\Lexeme\Domain\Model\ReadModel\LatestLexemeRevisionMetadataResult as MetadataResult; |
| 7 | use Wikibase\Lexeme\Domain\Services\LexemeRevisionMetadataRetriever; |
| 8 | use Wikibase\Lib\Store\EntityRevisionLookup; |
| 9 | |
| 10 | /** |
| 11 | * @license GPL-2.0-or-later |
| 12 | */ |
| 13 | class EntityRevisionLookupLexemeRevisionMetadataRetriever implements LexemeRevisionMetadataRetriever { |
| 14 | |
| 15 | public function __construct( private EntityRevisionLookup $revisionLookup ) { |
| 16 | } |
| 17 | |
| 18 | public function getLatestRevisionMetadata( LexemeId $lexemeId ): MetadataResult { |
| 19 | return $this->revisionLookup->getLatestRevisionId( $lexemeId ) |
| 20 | ->onConcreteRevision( MetadataResult::concreteRevision( ... ) ) |
| 21 | ->onNonexistentEntity( static fn () => MetadataResult::lexemeNotFound() ) |
| 22 | ->onRedirect( |
| 23 | static fn ( int $revId, LexemeId $redirectTarget ) => MetadataResult::redirect( $redirectTarget ) |
| 24 | ) |
| 25 | ->map(); |
| 26 | } |
| 27 | } |