]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - extensions/LocalisationUpdate/fetcher/FetcherFactory.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / extensions / LocalisationUpdate / fetcher / FetcherFactory.php
diff --git a/extensions/LocalisationUpdate/fetcher/FetcherFactory.php b/extensions/LocalisationUpdate/fetcher/FetcherFactory.php
new file mode 100644 (file)
index 0000000..570dc7e
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+namespace LocalisationUpdate;
+
+/**
+ * Constructs fetchers based on the repository urls.
+ */
+class FetcherFactory {
+       public function getFetcher( $path ) {
+               if ( strpos( $path, 'https://raw.github.com/' ) === 0 ) {
+                       return new GitHubFetcher();
+               } elseif ( strpos( $path, 'http://' ) === 0 ) {
+                       return new HttpFetcher();
+               } elseif ( strpos( $path, 'https://' ) === 0 ) {
+                       return new HttpFetcher();
+               } else {
+                       return new FileSystemFetcher();
+               }
+       }
+}