PluginProbe
ManageWP Worker / 4.0.1
ManageWP Worker v4.0.1
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / Dropbox / Host.php

Host.php in ManageWP Worker 4.0.1, at src/Dropbox/Host.php

116 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The Dropbox web API accesses three hosts; this structure holds the
5 * names of those three hosts. This is primarily for mocking things out
6 * during testing. Most of the time you won't have to deal with this class
7 * directly, and even when you do, you'll just use the default
8 * value: {@link Host::getDefault()}.
9 *
10 * @internal
11 */
12 final class Dropbox_Host
13 {
14 /**
15 * Returns a Host object configured with the three standard Dropbox host: "api.dropbox.com",
16 * "api-content.dropbox.com", and "www.dropbox.com"
17 *
18 * @return Dropbox_Host
19 */
20 public static function getDefault()
21 {
22 if (!self::$defaultValue) {
23 self::$defaultValue = new self("api.dropbox.com", "api-content.dropbox.com", "www.dropbox.com");
24 }
25
26 return self::$defaultValue;
27 }
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 public 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 public function getApi()
62 {
63 return $this->api;
64 }
65
66 /**
67 * Returns the host name of the Dropbox API content server.
68 * The default is "api-content.dropbox.com".
69 *
70 * @return string
71 */
72 public function getContent()
73 {
74 return $this->content;
75 }
76
77 /**
78 * Returns the host name of the Dropbox web server. Used during user authorization.
79 * The default is "www.dropbox.com".
80 *
81 * @return string
82 */
83 public function getWeb()
84 {
85 return $this->web;
86 }
87
88 /**
89 * Check that a function argument is of type <code>Host</code>.
90 *
91 * @internal
92 */
93 public static function checkArg($argName, $argValue)
94 {
95 if (!($argValue instanceof self)) {
96 Dropbox_Checker::throwError($argName, $argValue, __CLASS__);
97 }
98 }
99
100 /**
101 * Check that a function argument is either <code>null</code> or of type
102 * <code>Host</code>.
103 *
104 * @internal
105 */
106 public static function checkArgOrNull($argName, $argValue)
107 {
108 if ($argValue === null) {
109 return;
110 }
111 if (!($argValue instanceof self)) {
112 Dropbox_Checker::throwError($argName, $argValue, __CLASS__);
113 }
114 }
115 }
116