Exception
6 years ago
WebAuthException
6 years ago
certs
6 years ago
AppInfo.php
6 years ago
AppInfoLoadException.php
6 years ago
ArrayEntryStore.php
6 years ago
AuthBase.php
6 years ago
AuthInfo.php
6 years ago
AuthInfoLoadException.php
6 years ago
Checker.php
6 years ago
Client.php
6 years ago
Curl.php
6 years ago
CurlStreamRelay.php
6 years ago
DeserializeException.php
6 years ago
DropboxMetadataHeaderCatcher.php
6 years ago
Exception.php
6 years ago
Host.php
6 years ago
HttpResponse.php
6 years ago
OAuth1AccessToken.php
6 years ago
OAuth1Upgrader.php
6 years ago
Path.php
6 years ago
RequestUtil.php
6 years ago
RootCertificates.php
6 years ago
SSLTester.php
6 years ago
Security.php
6 years ago
StreamReadException.php
6 years ago
Util.php
6 years ago
ValueStore.php
6 years ago
WebAuth.php
6 years ago
WebAuthBase.php
6 years ago
WebAuthNoRedirect.php
6 years ago
WriteMode.php
6 years ago
autoload.php
6 years ago
strict.php
6 years ago
Host.php
101 lines
| 1 | <?php |
| 2 | namespace Dropbox; |
| 3 | |
| 4 | /** |
| 5 | * The Dropbox web API accesses three hosts; this structure holds the |
| 6 | * names of those three hosts. This is primarily for mocking things out |
| 7 | * during testing. Most of the time you won't have to deal with this class |
| 8 | * directly, and even when you do, you'll just use the default |
| 9 | * value: {@link Host::getDefault()}. |
| 10 | * |
| 11 | * @internal |
| 12 | */ |
| 13 | final class Host |
| 14 | { |
| 15 | /** |
| 16 | * Returns a Host object configured with the three standard Dropbox host: "api.dropbox.com", |
| 17 | * "api-content.dropbox.com", and "www.dropbox.com" |
| 18 | * |
| 19 | * @return Host |
| 20 | */ |
| 21 | static function getDefault() |
| 22 | { |
| 23 | if (!self::$defaultValue) { |
| 24 | //self::$defaultValue = new Host("api.dropbox.com", "api-content.dropbox.com", "www.dropbox.com"); |
| 25 | self::$defaultValue = new Host("api.dropboxapi.com", "content.dropboxapi.com", "www.dropbox.com"); |
| 26 | } |
| 27 | return self::$defaultValue; |
| 28 | } |
| 29 | private static $defaultValue; |
| 30 | |
| 31 | /** @var string */ |
| 32 | private $api; |
| 33 | /** @var string */ |
| 34 | private $content; |
| 35 | /** @var string */ |
| 36 | private $web; |
| 37 | |
| 38 | /** |
| 39 | * Constructor. |
| 40 | * |
| 41 | * @param string $api |
| 42 | * See {@link getApi()} |
| 43 | * @param string $content |
| 44 | * See {@link getContent()} |
| 45 | * @param string $web |
| 46 | * See {@link getWeb()} |
| 47 | */ |
| 48 | function __construct($api, $content, $web) |
| 49 | { |
| 50 | $this->api = $api; |
| 51 | $this->content = $content; |
| 52 | $this->web = $web; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the host name of the main Dropbox API server. |
| 57 | * The default is "api.dropbox.com". |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | function getApi() { return $this->api; } |
| 62 | |
| 63 | /** |
| 64 | * Returns the host name of the Dropbox API content server. |
| 65 | * The default is "api-content.dropbox.com". |
| 66 | * |
| 67 | * @return string |
| 68 | */ |
| 69 | function getContent() { return $this->content; } |
| 70 | |
| 71 | /** |
| 72 | * Returns the host name of the Dropbox web server. Used during user authorization. |
| 73 | * The default is "www.dropbox.com". |
| 74 | * |
| 75 | * @return string |
| 76 | */ |
| 77 | function getWeb() { return $this->web; } |
| 78 | |
| 79 | /** |
| 80 | * Check that a function argument is of type <code>Host</code>. |
| 81 | * |
| 82 | * @internal |
| 83 | */ |
| 84 | static function checkArg($argName, $argValue) |
| 85 | { |
| 86 | if (!($argValue instanceof self)) Checker::throwError($argName, $argValue, __CLASS__); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Check that a function argument is either <code>null</code> or of type |
| 91 | * <code>Host</code>. |
| 92 | * |
| 93 | * @internal |
| 94 | */ |
| 95 | static function checkArgOrNull($argName, $argValue) |
| 96 | { |
| 97 | if ($argValue === null) return; |
| 98 | if (!($argValue instanceof self)) Checker::throwError($argName, $argValue, __CLASS__); |
| 99 | } |
| 100 | } |
| 101 |