-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectorInterface.php
100 lines (87 loc) · 2.51 KB
/
ConnectorInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace dLdL\WebService;
use dLdL\WebService\Adapter\CacheHelperInterface;
use dLdL\WebService\Exception\ConnectionException;
use dLdL\WebService\Adapter\ParameterBag;
use Psr\Log\LoggerInterface;
use dLdL\WebService\Http\Request;
/**
* ConnectorInterface defines rules to connect to a WebService.
*/
interface ConnectorInterface
{
/**
* Initialize the connector and the connection to the host if needed.
*
* @param string $host Host of the webservice
*
* @throws ConnectionException if connection fails
*/
public function connect($host);
/**
* Get the current connector host.
*
* @throws ConnectionException if connector is not connected and initialized
*
* @see ConnectorInterface::isConnected() to check if connector is connected
*
* @return string The current hostname
*/
public function getHost();
/**
* Check if the connector is initialized and connected if needed.
*
* @return bool true if this connector can handle requests
*/
public function isConnected();
/**
* Disconnect the connector and free resources.
*/
public function disconnect();
/**
* Check if the connector supports a specific request method.
*
* @param string $method The method to be checked, for instance : 'GET', 'POST', ...
*
* @return bool true if the method can be handled
*/
public function supportsMethod($method);
/**
* Send a request to the WebService.
*
* @param Request $request The request to be send
*
* @return mixed The raw request answer
*/
public function sendRequest(Request $request);
/**
* Get the defined parameters of the connector.
*
* @return ParameterBag The ParameterBag with defined parameters
*/
public function getParameters();
/**
* Set or remove a cache handler.
*
* @param CacheHelperInterface|null $cache The cache handler to be set or null to remove the current cache handler
*/
public function setCache(CacheHelperInterface $cache = null);
/**
* Check if a cache handler is defined for the parameters.
*
* @return bool
*/
public function hasCache();
/**
* Get the current configured cache.
*
* @return CacheHelperInterface
*/
public function getCache();
/**
* Set a logger to log WebServices access.
*
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger);
}