for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare( strict_types = 1 );
namespace Maps\DataAccess;
use Maps\FileUrlFinder;
use RepoGroup;
/**
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
class MediaWikiFileUrlFinder implements FileUrlFinder {
public function getUrlForFileName( string $fileName ): string {
$colonPosition = strpos( $fileName, ':' );
$titleWithoutPrefix = $colonPosition === false ? $fileName : substr( $fileName, $colonPosition + 1 );
$file = RepoGroup::singleton()->findFile( trim( $titleWithoutPrefix ) );
if ( $file && $file->exists() ) {
return $file->getURL();
}
return trim( $fileName );