mediawiki-extensions-Descri.../includes/DescriptionProvider.php
alex4401 b73fe26c29 Extract description algorithm into a new class
Separating the extract algorithm from integration code. This results in a slightly cleaner code structure (at least in my opinion) and enables adding alternate algorithms without devolving into spaghetti.

The DescriptionProvider (name of the new base interface) is exposed as a service through dependency injection to avoid factories. The implementation can be swapped at service instantiation time.

Depends-On: I73c61ce045dcf31ac1ca5888f1548de8fd8b56ff
Change-Id: I97fd065c9554837747021ba9fff26005e33270f4
2024-01-12 08:24:19 +00:00

14 lines
297 B
PHP

<?php
namespace MediaWiki\Extension\Description2;
interface DescriptionProvider {
/**
* Extracts description from the HTML representation of a page.
*
* @param string $text HTML to extract the description from.
* @return ?string
*/
public function derive( string $text ): ?string;
}