Git *wants* to rewrite this file in the exact same way...

Probably a line ending issue...
This commit is contained in:
ArthurHoaro 2016-01-06 20:40:17 +01:00
parent 88c15abb2a
commit c0a50f3663

View file

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