Passed
Pull Request — feature/eco-2295/dev (#1)
by Aleksey
06:04 queued 04:31
created

CrefoPayApiBusinessFactory::createReserveClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\CrefoPayApi\Business;
9
10
use GuzzleHttp\Client;
0 ignored issues
show
Bug introduced by
The type GuzzleHttp\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use GuzzleHttp\ClientInterface;
0 ignored issues
show
Bug introduced by
The type GuzzleHttp\ClientInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
0 ignored issues
show
Bug introduced by
The type Spryker\Zed\Kernel\Busin...AbstractBusinessFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SprykerEco\Service\CrefoPayApi\CrefoPayApiServiceInterface;
14
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CancelRequestBuilder;
15
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CaptureRequestBuilder;
16
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CreateTransactionRequestBuilder;
17
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface;
18
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\FinishRequestBuilder;
19
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\RefundRequestBuilder;
20
use SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\ReserveRequestBuilder;
21
use SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClient;
22
use SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface;
23
use SprykerEco\Zed\CrefoPayApi\Business\Converter\CancelConverter;
24
use SprykerEco\Zed\CrefoPayApi\Business\Converter\CaptureConverter;
25
use SprykerEco\Zed\CrefoPayApi\Business\Converter\CreateTransactionConverter;
26
use SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface;
27
use SprykerEco\Zed\CrefoPayApi\Business\Converter\FinishConverter;
28
use SprykerEco\Zed\CrefoPayApi\Business\Converter\RefundConverter;
29
use SprykerEco\Zed\CrefoPayApi\Business\Converter\ReserveConverter;
30
use SprykerEco\Zed\CrefoPayApi\Business\Logger\CrefoPayApiLogger;
31
use SprykerEco\Zed\CrefoPayApi\Business\Logger\CrefoPayApiLoggerInterface;
32
use SprykerEco\Zed\CrefoPayApi\Business\Request\CancelRequest;
33
use SprykerEco\Zed\CrefoPayApi\Business\Request\CaptureRequest;
34
use SprykerEco\Zed\CrefoPayApi\Business\Request\CreateTransactionRequest;
35
use SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface;
36
use SprykerEco\Zed\CrefoPayApi\Business\Request\FinishRequest;
37
use SprykerEco\Zed\CrefoPayApi\Business\Request\RefundRequest;
38
use SprykerEco\Zed\CrefoPayApi\Business\Request\ReserveRequest;
39
use SprykerEco\Zed\CrefoPayApi\CrefoPayApiDependencyProvider;
40
use SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface;
41
42
/**
43
 * @method \SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig getConfig()
44
 * @method \SprykerEco\Zed\CrefoPayApi\Persistence\CrefoPayApiEntityManagerInterface getEntityManager()
45
 */
46
class CrefoPayApiBusinessFactory extends AbstractBusinessFactory
47
{
48
    /**
49
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
50
     */
51
    public function createCreateTransactionClient(): CrefoPayApiClientInterface
52
    {
53
        return new CrefoPayApiClient(
54
            $this->createGuzzleClient(),
55
            $this->createCreateTransactionRequest(),
56
            $this->createCreateTransactionConverter(),
57
            $this->createLogger()
58
        );
59
    }
60
61
    /**
62
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
63
     */
64
    public function createReserveClient(): CrefoPayApiClientInterface
65
    {
66
        return new CrefoPayApiClient(
67
            $this->createGuzzleClient(),
68
            $this->createReserveRequest(),
69
            $this->createReserveConverter(),
70
            $this->createLogger()
71
        );
72
    }
73
74
    /**
75
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
76
     */
77
    public function createCaptureClient(): CrefoPayApiClientInterface
78
    {
79
        return new CrefoPayApiClient(
80
            $this->createGuzzleClient(),
81
            $this->createCaptureRequest(),
82
            $this->createCancelConverter(),
83
            $this->createLogger()
84
        );
85
    }
86
87
    /**
88
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
89
     */
90
    public function createCancelClient(): CrefoPayApiClientInterface
91
    {
92
        return new CrefoPayApiClient(
93
            $this->createGuzzleClient(),
94
            $this->createCancelRequest(),
95
            $this->createCancelConverter(),
96
            $this->createLogger()
97
        );
98
    }
99
100
    /**
101
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
102
     */
103
    public function createRefundClient(): CrefoPayApiClientInterface
104
    {
105
        return new CrefoPayApiClient(
106
            $this->createGuzzleClient(),
107
            $this->createRefundRequest(),
108
            $this->createRefundConverter(),
109
            $this->createLogger()
110
        );
111
    }
112
113
    /**
114
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface
115
     */
116
    public function createFinishClient(): CrefoPayApiClientInterface
117
    {
118
        return new CrefoPayApiClient(
119
            $this->createGuzzleClient(),
120
            $this->createFinishRequest(),
121
            $this->createFinishConverter(),
122
            $this->createLogger()
123
        );
124
    }
125
126
    /**
127
     * @return \GuzzleHttp\ClientInterface
128
     */
129
    public function createGuzzleClient(): ClientInterface
130
    {
131
        return new Client();
132
    }
133
134
    /**
135
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
136
     */
137
    public function createCreateTransactionRequest(): CrefoPayApiRequestInterface
138
    {
139
        return new CreateTransactionRequest(
140
            $this->createCreateTransactionRequestBuilder(),
141
            $this->getConfig()
142
        );
143
    }
144
145
    /**
146
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
147
     */
148
    public function createReserveRequest(): CrefoPayApiRequestInterface
149
    {
150
        return new ReserveRequest(
151
            $this->createReserveRequestBuilder(),
152
            $this->getConfig()
153
        );
154
    }
155
156
    /**
157
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
158
     */
159
    public function createCaptureRequest(): CrefoPayApiRequestInterface
160
    {
161
        return new CaptureRequest(
162
            $this->createCaptureRequestBuilder(),
163
            $this->getConfig()
164
        );
165
    }
166
167
    /**
168
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
169
     */
170
    public function createCancelRequest(): CrefoPayApiRequestInterface
171
    {
172
        return new CancelRequest(
173
            $this->createCancelRequestBuilder(),
174
            $this->getConfig()
175
        );
176
    }
177
178
    /**
179
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
180
     */
181
    public function createRefundRequest(): CrefoPayApiRequestInterface
182
    {
183
        return new RefundRequest(
184
            $this->createRefundRequestBuilder(),
185
            $this->getConfig()
186
        );
187
    }
188
189
    /**
190
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface
191
     */
192
    public function createFinishRequest(): CrefoPayApiRequestInterface
193
    {
194
        return new FinishRequest(
195
            $this->createFinishRequestBuilder(),
196
            $this->getConfig()
197
        );
198
    }
199
200
    /**
201
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
202
     */
203
    public function createCreateTransactionRequestBuilder(): CrefoPayApiRequestBuilderInterface
204
    {
205
        return new CreateTransactionRequestBuilder(
206
            $this->getUtilEncodingService(),
207
            $this->getCrefoPayApiService()
208
        );
209
    }
210
211
    /**
212
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
213
     */
214
    public function createReserveRequestBuilder(): CrefoPayApiRequestBuilderInterface
215
    {
216
        return new ReserveRequestBuilder(
217
            $this->getUtilEncodingService(),
218
            $this->getCrefoPayApiService()
219
        );
220
    }
221
222
    /**
223
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
224
     */
225
    public function createCaptureRequestBuilder(): CrefoPayApiRequestBuilderInterface
226
    {
227
        return new CaptureRequestBuilder(
228
            $this->getUtilEncodingService(),
229
            $this->getCrefoPayApiService()
230
        );
231
    }
232
233
    /**
234
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
235
     */
236
    public function createCancelRequestBuilder(): CrefoPayApiRequestBuilderInterface
237
    {
238
        return new CancelRequestBuilder(
239
            $this->getUtilEncodingService(),
240
            $this->getCrefoPayApiService()
241
        );
242
    }
243
244
    /**
245
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
246
     */
247
    public function createRefundRequestBuilder(): CrefoPayApiRequestBuilderInterface
248
    {
249
        return new RefundRequestBuilder(
250
            $this->getUtilEncodingService(),
251
            $this->getCrefoPayApiService()
252
        );
253
    }
254
255
    /**
256
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Builder\Request\CrefoPayApiRequestBuilderInterface
257
     */
258
    public function createFinishRequestBuilder(): CrefoPayApiRequestBuilderInterface
259
    {
260
        return new FinishRequestBuilder(
261
            $this->getUtilEncodingService(),
262
            $this->getCrefoPayApiService()
263
        );
264
    }
265
266
    /**
267
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
268
     */
269
    public function createCreateTransactionConverter(): CrefoPayApiConverterInterface
270
    {
271
        return new CreateTransactionConverter($this->getUtilEncodingService());
272
    }
273
274
    /**
275
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
276
     */
277
    public function createReserveConverter(): CrefoPayApiConverterInterface
278
    {
279
        return new ReserveConverter($this->getUtilEncodingService());
280
    }
281
282
    /**
283
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
284
     */
285
    public function createCaptureConverter(): CrefoPayApiConverterInterface
286
    {
287
        return new CaptureConverter($this->getUtilEncodingService());
288
    }
289
290
    /**
291
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
292
     */
293
    public function createCancelConverter(): CrefoPayApiConverterInterface
294
    {
295
        return new CancelConverter($this->getUtilEncodingService());
296
    }
297
298
    /**
299
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
300
     */
301
    public function createRefundConverter(): CrefoPayApiConverterInterface
302
    {
303
        return new RefundConverter($this->getUtilEncodingService());
304
    }
305
306
    /**
307
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Converter\CrefoPayApiConverterInterface
308
     */
309
    public function createFinishConverter(): CrefoPayApiConverterInterface
310
    {
311
        return new FinishConverter($this->getUtilEncodingService());
312
    }
313
314
    /**
315
     * @return \SprykerEco\Zed\CrefoPayApi\Business\Logger\CrefoPayApiLoggerInterface
316
     */
317
    public function createLogger(): CrefoPayApiLoggerInterface
318
    {
319
        return new CrefoPayApiLogger($this->getEntityManager());
320
    }
321
322
    /**
323
     * @return \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface
324
     */
325
    public function getUtilEncodingService(): CrefoPayApiToUtilEncodingServiceInterface
326
    {
327
        return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_UTIL_ENCODING);
328
    }
329
330
    /**
331
     * @return \SprykerEco\Service\CrefoPayApi\CrefoPayApiServiceInterface
332
     */
333
    public function getCrefoPayApiService(): CrefoPayApiServiceInterface
334
    {
335
        return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_CREFO_PAY_API);
336
    }
337
}
338