summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/LocalisationUpdate/includes/Fetcher/FetcherFactory.php')
-rw-r--r--MLEB/LocalisationUpdate/includes/Fetcher/FetcherFactory.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/MLEB/LocalisationUpdate/includes/Fetcher/FetcherFactory.php b/MLEB/LocalisationUpdate/includes/Fetcher/FetcherFactory.php
new file mode 100644
index 00000000..4bb05132
--- /dev/null
+++ b/MLEB/LocalisationUpdate/includes/Fetcher/FetcherFactory.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+namespace LocalisationUpdate\Fetcher;
+
+/**
+ * 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();
+ }
+ }
+}