1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the WrikePhpSdk package. |
4
|
|
|
* |
5
|
|
|
* (c) Zbigniew Ślązak |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Zibios\WrikePhpSdk\Api; |
12
|
|
|
|
13
|
|
|
use GuzzleHttp\ClientInterface; |
14
|
|
|
use JMS\Serializer\SerializerInterface; |
15
|
|
|
use Zibios\WrikePhpSdk\Api\Configs\ResponseClassesConfig; |
16
|
|
|
use Zibios\WrikePhpSdk\Enums\ResponseModeEnum; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Config |
20
|
|
|
*/ |
21
|
|
|
class Config implements ConfigInterface |
22
|
|
|
{ |
23
|
|
|
/****************************************** |
24
|
|
|
* General Properties |
25
|
|
|
*****************************************/ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var ClientInterface |
29
|
|
|
*/ |
30
|
|
|
protected $client; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var SerializerInterface |
34
|
|
|
*/ |
35
|
|
|
protected $serializer; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
* @see ResponseModeEnum |
40
|
|
|
*/ |
41
|
|
|
protected $responseMode = ResponseModeEnum::DOCUMENT; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var boolean |
45
|
|
|
*/ |
46
|
|
|
protected $wrikeExceptionsMode = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var ResponseClassesConfig |
50
|
|
|
*/ |
51
|
|
|
protected $responseClasses; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return ClientInterface |
55
|
|
|
*/ |
56
|
56 |
|
public function getClient() |
57
|
|
|
{ |
58
|
56 |
|
return $this->client; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param ClientInterface $client |
63
|
|
|
* |
64
|
|
|
* @return $this |
65
|
|
|
*/ |
66
|
58 |
|
public function setClient(ClientInterface $client) |
67
|
|
|
{ |
68
|
58 |
|
$this->client = $client; |
69
|
|
|
|
70
|
58 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return SerializerInterface|null |
75
|
|
|
*/ |
76
|
22 |
|
public function getSerializer() |
77
|
|
|
{ |
78
|
22 |
|
return $this->serializer; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param SerializerInterface|null $serializer |
83
|
|
|
* |
84
|
|
|
* @return $this |
85
|
|
|
*/ |
86
|
58 |
|
public function setSerializer(SerializerInterface $serializer = null) |
87
|
|
|
{ |
88
|
58 |
|
$this->serializer = $serializer; |
89
|
|
|
|
90
|
58 |
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @see ResponseModeEnum |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
21 |
|
public function getResponseMode() |
98
|
|
|
{ |
99
|
21 |
|
return $this->responseMode; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $responseMode |
104
|
|
|
* |
105
|
|
|
* @see ResponseModeEnum |
106
|
|
|
* @throws \InvalidArgumentException |
107
|
|
|
* @return $this |
108
|
|
|
*/ |
109
|
58 |
|
public function setResponseMode($responseMode) |
110
|
|
|
{ |
111
|
58 |
|
ResponseModeEnum::assertIsValidValue($responseMode); |
112
|
58 |
|
$this->responseMode = $responseMode; |
113
|
|
|
|
114
|
58 |
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return bool |
119
|
|
|
*/ |
120
|
35 |
|
public function isWrikeExceptionsMode() |
121
|
|
|
{ |
122
|
35 |
|
return (boolean) $this->wrikeExceptionsMode; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param bool $wrikeExceptionsMode |
127
|
|
|
* |
128
|
|
|
* @return $this |
129
|
|
|
*/ |
130
|
57 |
|
public function setWrikeExceptionsMode($wrikeExceptionsMode) |
131
|
|
|
{ |
132
|
57 |
|
$this->wrikeExceptionsMode = (boolean) $wrikeExceptionsMode; |
133
|
|
|
|
134
|
57 |
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return ResponseClassesConfig |
139
|
|
|
*/ |
140
|
54 |
|
public function getResponseClasses() |
141
|
|
|
{ |
142
|
54 |
|
if ($this->responseClasses === null) { |
143
|
54 |
|
$this->responseClasses = new ResponseClassesConfig(); |
144
|
|
|
} |
145
|
|
|
|
146
|
54 |
|
return $this->responseClasses; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param ResponseClassesConfig $responseClasses |
151
|
|
|
* |
152
|
|
|
* @return $this |
153
|
|
|
*/ |
154
|
|
|
public function setResponseClasses(ResponseClassesConfig $responseClasses) |
155
|
|
|
{ |
156
|
|
|
$this->responseClasses = $responseClasses; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|