PluginProbe
JetBackup – Backup, Restore & Migrate / 1.4.6
JetBackup – Backup, Restore & Migrate v1.4.6
3.1.23.6 3.1.23.5 3.1.23.3 3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 All 82 releases
backup / com / lib / Dropbox / Host.php
Host.php
101 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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