MediaWiki  master
UnicodeConstraint.php
Go to the documentation of this file.
1 <?php
22 
23 use StatusValue;
24 
32 
37  public const VALID_UNICODE = 'ℳ𝒲β™₯π“Šπ“ƒπ’Ύπ’Έβ„΄π’Ήβ„―';
38 
43  private $input;
44 
48  public function __construct( string $inputUnicode ) {
49  $this->input = $inputUnicode;
50  }
51 
52  public function checkConstraint(): string {
53  if ( $this->input === self::VALID_UNICODE ) {
54  return self::CONSTRAINT_PASSED;
55  }
56  return self::CONSTRAINT_FAILED;
57  }
58 
59  public function getLegacyStatus(): StatusValue {
60  $statusValue = StatusValue::newGood();
61  if ( $this->input !== self::VALID_UNICODE ) {
62  $statusValue->fatal( 'unicode-support-fail' );
63  $statusValue->value = self::AS_UNICODE_NOT_SUPPORTED;
64  }
65  return $statusValue;
66  }
67 
68 }
if(!defined('MW_SETUP_CALLBACK'))
Definition: WebStart.php:88
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:46
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Interface for all constraints that can prevent edits.