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 }
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:43
MediaWiki\EditPage\Constraint\UnicodeConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition: UnicodeConstraint.php:59
MediaWiki\EditPage\IEditObject\AS_UNICODE_NOT_SUPPORTED
const AS_UNICODE_NOT_SUPPORTED
Status: edit rejected because browser doesn't support Unicode.
Definition: IEditObject.php:121
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
MediaWiki\EditPage\Constraint\UnicodeConstraint\$input
string $input
Unicode string provided, to compare.
Definition: UnicodeConstraint.php:33
MediaWiki\EditPage\Constraint\UnicodeConstraint\checkConstraint
checkConstraint()
Definition: UnicodeConstraint.php:52
MediaWiki\EditPage\Constraint\UnicodeConstraint
Verify unicode constraint.
Definition: UnicodeConstraint.php:31
MediaWiki\EditPage\Constraint\UnicodeConstraint\__construct
__construct(string $inputUnicode)
Definition: UnicodeConstraint.php:48
MediaWiki\EditPage\Constraint
Definition: AccidentalRecreationConstraint.php:21
MediaWiki\EditPage\Constraint\IEditConstraint
Interface for all constraints that can prevent edits.
Definition: IEditConstraint.php:33