MediaWiki REL1_40
SpamChecker.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\EditPage;
4
15
17 private $spamRegex;
18
20 private $summaryRegex;
21
26 public function __construct( $spamRegex, $summaryRegex ) {
27 $this->spamRegex = $spamRegex;
28 $this->summaryRegex = $summaryRegex;
29 }
30
37 public function checkContent( string $text ) {
38 return self::checkInternal( $text, $this->spamRegex );
39 }
40
47 public function checkSummary( string $summary ) {
48 return self::checkInternal( $summary, $this->summaryRegex );
49 }
50
56 private static function checkInternal( string $text, array $regexes ) {
57 foreach ( $regexes as $regex ) {
58 $matches = [];
59 if ( preg_match( $regex, $text, $matches ) ) {
60 return $matches[0];
61 }
62 }
63 return false;
64 }
65}
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( $spamRegex, $summaryRegex)