summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Translate/src/PageTranslation/TranslatablePageStatus.php')
-rw-r--r--Translate/src/PageTranslation/TranslatablePageStatus.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/Translate/src/PageTranslation/TranslatablePageStatus.php b/Translate/src/PageTranslation/TranslatablePageStatus.php
new file mode 100644
index 00000000..02a3f25c
--- /dev/null
+++ b/Translate/src/PageTranslation/TranslatablePageStatus.php
@@ -0,0 +1,37 @@
+<?php
+declare( strict_types = 1 );
+
+namespace MediaWiki\Extension\Translate\PageTranslation;
+
+use InvalidArgumentException;
+use MediaWiki\Extension\Translate\MessageGroupProcessing\TranslatableBundleStatus;
+
+/**
+ * Stores and validates possible statuses for TranslatablePage
+ * @author Abijeet Patro
+ * @since 2022.09
+ * @license GPL-2.0-or-later
+ */
+class TranslatablePageStatus implements TranslatableBundleStatus {
+ public const PROPOSED = 1;
+ public const ACTIVE = 2;
+ public const OUTDATED = 3;
+ public const BROKEN = 4;
+
+ private $status;
+
+ public function __construct( int $status ) {
+ if ( !in_array( $status, [ self::PROPOSED, self::ACTIVE, self::OUTDATED, self::BROKEN ] ) ) {
+ throw new InvalidArgumentException( "Invalid status: $status" );
+ }
+ $this->status = $status;
+ }
+
+ public function isEqual( int $status ): bool {
+ return $this->status === $status;
+ }
+
+ public function getId(): int {
+ return $this->status;
+ }
+}