1 | <?php |
||
9 | class Credentials |
||
10 | { |
||
11 | /** |
||
12 | * A sprintf format for creating a node address |
||
13 | */ |
||
14 | const ADDRESS_FORMAT = '%s:%d'; |
||
15 | |||
16 | /** |
||
17 | * @var string A Disque server host or IP address |
||
18 | */ |
||
19 | private $host; |
||
20 | |||
21 | /** |
||
22 | * @var int The server port |
||
23 | */ |
||
24 | private $port; |
||
25 | |||
26 | /** |
||
27 | * @var string|null The password if set for this server |
||
28 | */ |
||
29 | private $password; |
||
30 | |||
31 | /** |
||
32 | * @var int|null The maximum seconds to wait for a connection to the server |
||
33 | */ |
||
34 | private $connectionTimeout; |
||
35 | |||
36 | /** |
||
37 | * @var int|null The maximum seconds to wait for a response from the server |
||
38 | */ |
||
39 | private $responseTimeout; |
||
40 | |||
41 | /** |
||
42 | * @param string $host |
||
43 | * @param int $port |
||
44 | * @param string|null $password |
||
45 | * @param int|null $connectionTimeout |
||
46 | * @param int|null $responseTimeout |
||
47 | */ |
||
48 | public function __construct( |
||
61 | |||
62 | /** |
||
63 | * Get the server host |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function getHost() |
||
71 | |||
72 | /** |
||
73 | * Get the server port |
||
74 | * |
||
75 | * @return int |
||
76 | */ |
||
77 | public function getPort() |
||
81 | |||
82 | /** |
||
83 | * Get the server address |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getAddress() |
||
90 | |||
91 | /** |
||
92 | * Get the password needed to connect to the server |
||
93 | * |
||
94 | * Passwords in Disque are optional, servers should be secured in other ways |
||
95 | * |
||
96 | * @return null|string |
||
97 | */ |
||
98 | public function getPassword() |
||
102 | |||
103 | /** |
||
104 | * Check if the credentials have a password set |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function havePassword() |
||
112 | |||
113 | /** |
||
114 | * Get the maximum time in seconds to wait for a server connection |
||
115 | * |
||
116 | * @return int|null |
||
117 | */ |
||
118 | public function getConnectionTimeout() |
||
122 | |||
123 | /** |
||
124 | * Get the maximum time in seconds to wait for any server response |
||
125 | * |
||
126 | * @return int|null |
||
127 | */ |
||
128 | public function getResponseTimeout() |
||
132 | } |
||
133 |