-<?php\r
-\r
-/**\r
- * Class WallabagInstance.\r
- */\r
-class WallabagInstance\r
-{\r
- /**\r
- * @var array Static reference to differrent WB API versions.\r
- * - key: version ID, must match plugin settings.\r
- * - value: version name.\r
- */\r
- private static $wallabagVersions = array(\r
- 1 => '1.x',\r
- 2 => '2.x',\r
- );\r
-\r
- /**\r
- * @var array Static reference to WB endpoint according to the API version.\r
- * - key: version name.\r
- * - value: endpoint.\r
- */\r
- private static $wallabagEndpoints = array(\r
- '1.x' => '?plainurl=',\r
- '2.x' => 'bookmarklet?url=',\r
- );\r
-\r
- /**\r
- * @var string Wallabag user instance URL.\r
- */\r
- private $instanceUrl;\r
-\r
- /**\r
- * @var string Wallabag user instance API version.\r
- */\r
- private $apiVersion;\r
-\r
- function __construct($instance, $version)\r
- {\r
- if ($this->isVersionAllowed($version)) {\r
- $this->apiVersion = self::$wallabagVersions[$version];\r
- } else {\r
- // Default API version: 1.x.\r
- $this->apiVersion = self::$wallabagVersions[1];\r
- }\r
-\r
- $this->instanceUrl = add_trailing_slash($instance);\r
- }\r
-\r
- /**\r
- * Build the Wallabag URL to reach from instance URL and API version endpoint.\r
- *\r
- * @return string wallabag url.\r
- */\r
- public function getWallabagUrl()\r
- {\r
- return $this->instanceUrl . self::$wallabagEndpoints[$this->apiVersion];\r
- }\r
-\r
- /**\r
- * Checks version configuration.\r
- *\r
- * @param mixed $version given version ID.\r
- *\r
- * @return bool true if it's valid, false otherwise.\r
- */\r
- private function isVersionAllowed($version)\r
- {\r
- return isset(self::$wallabagVersions[$version]);\r
- }\r
-}\r
+<?php
+
+/**
+ * Class WallabagInstance.
+ */
+class WallabagInstance
+{
+ /**
+ * @var array Static reference to differrent WB API versions.
+ * - key: version ID, must match plugin settings.
+ * - value: version name.
+ */
+ private static $wallabagVersions = array(
+ 1 => '1.x',
+ 2 => '2.x',
+ );
+
+ /**
+ * @var array Static reference to WB endpoint according to the API version.
+ * - key: version name.
+ * - value: endpoint.
+ */
+ private static $wallabagEndpoints = array(
+ '1.x' => '?plainurl=',
+ '2.x' => 'bookmarklet?url=',
+ );
+
+ /**
+ * @var string Wallabag user instance URL.
+ */
+ private $instanceUrl;
+
+ /**
+ * @var string Wallabag user instance API version.
+ */
+ private $apiVersion;
+
+ function __construct($instance, $version)
+ {
+ if ($this->isVersionAllowed($version)) {
+ $this->apiVersion = self::$wallabagVersions[$version];
+ } else {
+ // Default API version: 1.x.
+ $this->apiVersion = self::$wallabagVersions[1];
+ }
+
+ $this->instanceUrl = add_trailing_slash($instance);
+ }
+
+ /**
+ * Build the Wallabag URL to reach from instance URL and API version endpoint.
+ *
+ * @return string wallabag url.
+ */
+ public function getWallabagUrl()
+ {
+ return $this->instanceUrl . self::$wallabagEndpoints[$this->apiVersion];
+ }
+
+ /**
+ * Checks version configuration.
+ *
+ * @param mixed $version given version ID.
+ *
+ * @return bool true if it's valid, false otherwise.
+ */
+ private function isVersionAllowed($version)
+ {
+ return isset(self::$wallabagVersions[$version]);
+ }
+}