MediaWiki master
SpamChecker.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\EditPage;
4
15
20 public function __construct(
21 private readonly array $spamRegex,
22 private readonly array $summaryRegex
23 ) {
24 }
25
32 public function checkContent( string $text ) {
33 return self::checkInternal( $text, $this->spamRegex );
34 }
35
42 public function checkSummary( string $summary ) {
43 return self::checkInternal( $summary, $this->summaryRegex );
44 }
45
51 private static function checkInternal( string $text, array $regexes ) {
52 foreach ( $regexes as $regex ) {
53 $matches = [];
54 if ( preg_match( $regex, $text, $matches ) ) {
55 return $matches[0];
56 }
57 }
58 return false;
59 }
60}
Service to check if text (either content or a summary) qualifies as spam.
checkSummary(string $summary)
Check whether summary text is considered spam.
checkContent(string $text)
Check whether content text is considered spam.
__construct(private readonly array $spamRegex, private readonly array $summaryRegex)