# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

EGIT_REPO_URI="https://github.com/thephpleague/mime-type-detection.git"

inherit git-r3

DESCRIPTION="League Mime Type Detection"
HOMEPAGE="https://github.com/thephpleague/mime-type-detection"

LICENSE="MIT"
SLOT="0"

RDEPEND="dev-lang/php:*[fileinfo]
	dev-php/fedora-autoloader"

src_prepare() {
	default

	install -D -m 644 "${FILESDIR}"/autoload.php \
		src/autoload.php || die "install failed"
	install -D -m 644 "${FILESDIR}"/autoload-test.php \
		vendor/autoload.php || die "install test failed"
	# remove test with failed assert
	sed -i '/the_generated_map_should_be_up_to_date/,+15d' \
		src/GeneratedExtensionToMimeTypeMapTest.php \
		|| die "sed failed for GeneratedExtensionToMimeTypeMapTest.php"
}

src_test() {
	phpunit --testdox || die "phpunit failed"
}

src_install() {
	einstalldocs
	insinto /usr/share/php/League/MimeTypeDetection
	doins -r src/.
}